How to override existing core view

Stephen J

New Member
Hi Mailwizz Members,
I am trying to add new field inside campaign setup form. But i dont have Hook exactly on that place. So how to include our html inbetween core view.

Thanks,
Developer
 
Hi twisted1919,

I am trying to override view file,
I am using hooks before_active_form_fields to add existing fields and adding extra fields. It seems only appending new view is possible .
Is there any way to replace the existing view with new content.

For example:

Existing view
Name field
phone field

New view
Name field
email field
phone field

I want to replace existing view to new view .. is that possible?
 
I saw this comment.. but its not working twisted1919
i used $collection->renderForm = false. but it not hiding default content.
/**
* This hook gives a chance to prepend content before the active form or to replace the default active form entirely.
* Please note that from inside the action callback you can access all the controller view variables
* via {@CAttributeCollection $collection->controller->data}
* In case the form is replaced, make sure to set {@CAttributeCollection $collection->renderForm} to false
* in order to stop rendering the default content.
* @since 1.3.3.1
*/
 
Hi twisted1919,

I am able to override, but now i have another problem

This is inside customer/config/main.php

PHP:
array('campaigns/<action>', 'pattern' => 'campaigns/<campaign_uid:([a-z0-9]+)>/<action:(\w+)>'),

In my extension i have added following urls
PHP:
            Yii::app()->urlManager->addRules(array(
                array('campaigns/setup', 'pattern' => 'campaigns/<campaign_uid:([a-z0-9]+)>/setup')
            ));

I hope this means when i execute my extension.. consider this campaigns/setup url... for other campaigns/<action> consider parent urlmanager.

But i am getting error like
Ext_previous_click_unclick_campaignsController cannot find the requested view "index".
I think index view should fetch from parent campaignsController view folder.. if its setup view then fetch from Ext_previous_click_unclick_campaignsController view folder..

Is that right?
 
@Stephen J - you do not have to add custom url rules to overwrite the core ones.

But i am getting error like
Ext_previous_click_unclick_campaignsController cannot find the requested view "index".
I think index view should fetch from parent campaignsController view folder.. if its setup view then fetch from Ext_previous_click_unclick_campaignsController view folder..
If in your controller you render your view like:
PHP:
$this->render('index');
Then the controller will look for a view file relative to the folder that contains the controller, in a folder called views/controller-id, so in this case you should have views/ext_previous_click_unclick_campaigns/index.php Remember, the view folder must be at same level as the controllers folder from your extension.

Alternatively, you can use a path alias, something like:
PHP:
$this->render('root.extensions.your-extension-name.views.index');
 
Hi Twisted1919,
you do not have to add custom url rules to overwrite the core ones.
If i am overriding core campaigns/setup view.. if anybody hits campaigns/setup url i have to hit my Extenstioncontroller and load my custom view, thats why i have given urlmanager inside my extension. is that wrong? without giving custom urlmanager, how it will trigger my extensioncontroller.

I will share my folder view here
previous-click-unclick\customer\campaign\view\setup.php
previous-click-unclick\common\data\install.sql
previous-click-unclick\common\data\uninstall.sql
previous-click-unclick\common\models\CampaignFilterClickUnclick.php
previous-click-unclick\PreviousClickUnclickExt.php

Inside my extension controller Action render method is working fine .. there is no problem. But problem occurs in redirect from extensioncontroller.Once successfully saved its redirect from setup to template stage, but that time also its looking Extension view instead of CampaignController View.
In that level i got below error
Ext_previous_click_unclick_campaignsController cannot find the requested view "index"
 
Hi Twisted1919,
You are right
I have removed url manager from my extension and getviewpath method from mycontroller..
and replace my render like this
$this->render('ext-previous-click-unclick.customer.view.campaign.step-setup');
Now its working fine..
 
Back
Top