Best way to extend a module in zend framework 2 - module

What is best way to extend zend framework 2 modules.
For example I want to change register page view in zfcuser , I cloned zfcuser module from vendor to modules folder and changed view files but Zend Framework 2 uses vendor folder one, If I delete zfcuser folder in vendor it works ok but two modules at same time uses vendor version

You don't have to clone the module. You can just create a zfc-user/user folder in your own module's view folder. And then place your own register.phtml in that folder. Just make sure that ZfcUser is included before your own custom module and then your own custom view should be loaded.
Edit: this is a link to the official docs on this topic: ZfcUser custom view scripts

If you only want to override template files just override the module.config.php in your Modul directory.
'view_manager' => array(
'template_path_stack' => array(
'zfcuser' => __DIR__ . '/../view',
),
),
Within your view directory add a folder called zfc-user and add a register.phtml file. Within that template file feel free to change whatever you want, just keep in mind that you still have to keep the form action as it is.

Related

How can I install a yii extension, making it available to my whole web application?

Recently I decided to study php and I discovered yii framework. At first glance it seemed very easy to work with it but now I am struggling to configure my web application for installing an extension to work with Enums. I downloaded this extension from their web site and I put it within extensions folder. The issue is that I am not able to call the subclasses that I created in my code. I created a few classes that extend from this superclass (extension).
Which configuration I must do to make this extension class, available to my web application code?
As I said I just put that extension class in my extensions folder and I am just instantiating them, inside controller's methods. When I run the code I see the same error message no matter any configuration I make:
include (xxx.php): failed to open stream: No such file or directory
If anyone does want to know more about this extension this is the page that shows some information about that.
http://www.yiiframework.com/extension/enum/
in config/main.php you should add your extension details in the components array, something like:
return array(
// 'preload'=>array('xyz',...),
'components'=>array(
'xyz'=>array(
'class'=>'ext.xyz.XyzClass',
'property1'=>'value1',
'property2'=>'value2',
),
// other component configurations
),
);
where xyz is an extension
or just put it in the extensions folder and import it by Yii::import('application.extensions.extensionname.*');

A Module For Installing Modules in Yii

I am wondering if there is a module that gives the ability to install modules via an interface instead of copy a module files and create database tables manually and add it to config/main.php .
Is there any ? I mean something like what is in Joomla or Drupal?
As of now, I don't think there is something like this on Yii.
What we did for our projects, is this.
We created our module, that will automatically create / copy the files and the same time, add the configuration files.

How to get the file upload button to show in the EditMe extension

I'm using the ExtEditMe extension in my project with the following configuration:
$this->widget('ext.editMe.widgets.ExtEditMe',
array(
'model'=>$model,
'attribute'=>'Text',
'ckeConfig'=>array('enableTabKeyTools'=>true,'enterMode'=>2),
'height'=>'500',
'width'=>'100%',
'filebrowserImageBrowseUrl'=>'/protected/extensions/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files'
)
);
For some reason the file upload button isn't showing in the tool bar. Is there something else I need to add?
Questions too much for a comment. Could you check the following:
Check the permissions for the assets folder. Need to be writable by your
httpd (example apache:apache or apache:www-data)
EditMe should be inside the protected/extensions/ folder
Change your widget call to:
$this->widget('application.extensions.editme.widgets.ExtEditMe',
(used full path)
Check if kcfinder/config.php says: 'disabled' => false,
Also, there may be a need to put kcfinder in the root of the webapp. See this example with CKeditor.
The following comes from the CKEDITOR docs:
This button will be hidden by default (hidden:true). The filebrowser plugin looks for all elements with the filebrowser attribute and unhides them if appropriate configuration setting is available (filebrowserBrowseUrl/filebrowserUploadUrl).
Which could mean your config settings for the filebrowser plugin are not correct. You should try the following:
KCFinder (your filebrowser plugin) is not a yii extension as far as I know, so move the kcfinder folder to the root folder (or any other folder outside of the protected folder).
Change the paths to the KCFinder files. I recommend using yii's Yii::app()->baseUrl to make sure you're getting the correct paths:
'filebrowserImageBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>Yii::app()->baseUrl.'/kcfinder/upload.php?type=files'
Hope that helps.
'filebrowserImageBrowseUrl'=>'/protected/extensions/kcfinder/browse.php?type=files',
'filebrowserImageUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserBrowseUrl'=>'/protected/extensions/kcfinder/upload.php?type=files',
'filebrowserUploadUrl'=>'/protected/extensions/kcfinder/upload.php?type=files'
These URLs will be passed to the Javascript initiator of the extension, and they will be requested from there, so you can copy them and try requesting them from the browser to see if they are working (I'm almost sure they won't work).
One way you can work this out, is by creating a controller and includes these PHP files there, then make these URLs refer to the controller you created. Hope it helps.

Prestashop 1.5, How to copy a core module into my theme module folder?

I'de like to copy the [prestashop new theme]cart block (cartblock2 in the main module folder) into my theme/modules in order to customize it and keep the core module intact.
How do I do that ? I searched the documentation and it's not very clear...
What I did so far :
Copy cartblock2 from the main module folder into my theme/module folder, empty prestashop cache (it's turned off but just to be sure), I made my changes but nothing change it's only changing when I modify the module in the main module folder.
Thank you for your help
module folder name must same with root modules name
/modules/blockcart2
in themes
/themes/modules/blockcart2
and you can only edit blockcart2.tpl file in themes folder
and make sure blockcart2 installed in bacoffice

Random folders being created on assets directory Yii

Can someone explain me why random folders are being created at assets directory of my Yii project. Since I am using SVN to control the versions, is it necessary to commit those folders as well ?
Those folders are the js, css, and image files needed for various widgets and other parts of the Yii framework. You do NOT want to commit them to a repository, as Yii automatically regenerates a fresh copy if they don't exist.
Just create the folder for it, wipe out the contents of the folder if you upgrade to new versions of widgets, and don't add them to your repo.
http://www.yiiframework.com/wiki/148/understanding-assets/