Suggesting to customize the campaign workflow

SenG

New Member
We are customizing mail-wizz for managing tenders and the app is being used only the company staff members.
  1. The campaign has to made available to all customers (here, our colleagues) regardless of who created it.
  2. When creating campaigns, instead of List, we should allow user to select subscribers (tenderers) from preexisting master list.
I'm able to modify the core script directly to have them done, but I'm looking for extending the script without touching core code base.

I'm thinking of extending all the controllers that requires customization and make modifications in the extended class. Something like,

TenderController extends CampaignsController {
//override methods
}

I noticed hooks, but hooks can be attached before or after certain actions, but I need to change the action itself.

Any ideas?
 

SenG

New Member
I resolved it this way.

  1. created a dir structure apps/custom/customer/{controller,views}
  2. created a new controller TenderController and extending it from CampaignsController
PHP:
Yii::import('root.apps.customer.controllers.*');
Yii::setPathOfAlias('views', Yii::getPathOfAlias('custom.customer.views'));

class TenderController extends CampaignsController {
}

3. In apps/common/config/main-custom.php​
PHP:
Yii::setPathOfAlias('custom', Yii::getPathOfAlias('root.apps.custom'));
    'controllerMap' => [
        'campaigns' => [
            'class' => 'root.apps.custom.customer.controllers.TenderController',
        ],
    ]

Do we have a better way?
 

twisted1919

Administrator
Staff member
@SenG - Here's how i do it.
I create a custom theme and from that theme i hook into Yii::app()->controllerMap where i add/override the existing controllers with mines.
PHP:
        // override default controller
        Yii::app()->controllerMap['site'] = array(
            'class' => 'theme-my-theme-frontend.controllers.MySiteController',
        );
You can see this pattern used in this theme that you can use it as a base for your own work.
When using a custom theme, not only you'll be able to change/extend controllers, load your own views, but you also can hook into actions/filters like you'd do from extensions.

Note that inside MyController.php you can require the original SiteController.php file and extend it to inherit the base functionality and only override what you need.

Also, if your theme has a views folder and inside you follow the structure from the mailwizz view folders, then the views from your theme will be loaded instead of the ones from mailwizz. You don't need to use all mailwizz views, use only what you want to override. When there are missing views, the ones from mailwizz are loaded.

Let me know if anything unclear.
 

frm.mwz

Well-Known Member
We are customizing mail-wizz for managing tenders and the app is being used only the company staff members.
  1. The campaign has to made available to all customers (here, our colleagues) regardless of who created it.
  2. When creating campaigns, instead of List, we should allow user to select subscribers (tenderers) from preexisting master list.
I'm able to modify the core script directly to have them done, but I'm looking for extending the script without touching core code base.

I'm thinking of extending all the controllers that requires customization and make modifications in the extended class. Something like,

TenderController extends CampaignsController {
//override methods
}

I noticed hooks, but hooks can be attached before or after certain actions, but I need to change the action itself.

Any ideas?

Have you tried a CRM making API calls to mwz?
 

SenG

New Member
@twisted1919 - Your solutions looks great & clean and get along with framework's ecosystem. But, I'm bit uncomfortable with require_once statement. I believe Yii::import() is more Yii way of doing things.

@frm.mwz - Looks like your question deviates from the original discussion point, but I did't. This is mostly REST API endpoints and should work without surprises. right?
 

frm.mwz

Well-Known Member
@twisted1919 - Your solutions looks great & clean and get along with framework's ecosystem. But, I'm bit uncomfortable with require_once statement. I believe Yii::import() is more Yii way of doing things.

@frm.mwz - Looks like your question deviates from the original discussion point, but I did't. This is mostly REST API endpoints and should work without surprises. right?

Note sure what you mean.

My suggestion was meant to give you another option to realize your goal so that you may not have to change your code when mwz updates.
 
Last edited:

twisted1919

Administrator
Staff member
@frm.mwz - from a programming standpoint, using extensions/themes is perfectly safe at upgrades, they are not changed in any way ;)
@SenG - Sure, you can use Yii::import if you wish, whatever makes more sense to you ;)
 
Top