I was thinking about extending all my controllers from the indexController. I have in the index controller a init() function that does alot of stuff. This is not executed upon fooController request.
I allready have a registered a viewSetup plugin. And this is executed on all requests and thats just fine.
My problem is a have blog module which needs to do some stuff, that don’t need to be done in the news module.
A good example is my secondary menu, its specific to the active module.
class fooController extends indexController In this way i could also override the init() function in indexController from within fooController. Unfortunately the autoloader can’t find the indexController class.
The following works though, if i require the indexController.php file first
<?php
require_once('indexController.php);
class fooController extends indexController {
function init() {
parent::init();
// Do changes to, ie. setup controller specific menu, or add menu items.
}
}
Ideas much appreciated 🙂
Possible solutions, depends what do you want to do:
Looks like the controller plugin is the best in this case (since you are already using one),
but you just need to add some conditions to it, e.g. execute the code only when specific module, controller and action are requested.