Hello all,
I want to generate a menu for every page. As one of the quickest method (am I
wrong here? are there quicker methods? at least it is quicker than calling
action() from template) is to register a plugin that adds in the stack of the
Zend_Front_Controller a new Zend_Controller_Request_Simple object. Because I
need to colour some things in the menu (make active a link), I need this action
executed after the dispatch process.
So I have this:
class Controller_Plugin_Menu extends Zend_Controller_Plugin_Abstract
{
protected $_stack;
public function postDispatch( Zend_Controller_Request_Abstract $request )
{
//var_dump( Zend_Controller_Front::getControllerDirectory() );
$stack = $this->getStack();
$leftMenuRequest = new Zend_Controller_Request_Simple();
$leftMenuRequest->setModuleName('edms')
->setControllerName('menu')
->setActionName('index');
$stack->pushStack($leftMenuRequest);
}
public function getStack()
{
if (null === $this->_stack) {
$front = Zend_Controller_Front::getInstance();
if (!$front->hasPlugin('Zend_Controller_Plugin_ActionStack')) {
$stack = new Zend_Controller_Plugin_ActionStack();
$front->registerPlugin($stack);
} else {
$stack = $front->getPlugin('ActionStack');
}
$this->_stack = $stack;
}
return $this->_stack;
}
}
The problem now is that this action is never executed . What is wrong? Do I
have to set some flags in order to get that action executed?
A second small question: How can get the list of all modules registered to the
Front_Controller from within that plugin?
Thank you very much,
Andrei