What is an alternitive for using action(); or forward(); in ZF for pulling out different controller/actions in the layout?
Basically in order to have a profile Block u need - let's say profile controller, PhotoController, may be dashboard to show at the same page at the same time and to reac开发者_JS百科h this in the zend framework is sometimes done through helper action() or forward, are ther better options?
I'm not sure I understood your question clearly. But you should avoid the action helper because it decreases significantly the performance of your application.
"The Action View helper basically creates an additional dispatch, copying the request object, and creating a loop-within-a-loop . The setting up of the dispatch process is a costly one, anyone who has profiled their code will have seen just how much of the process of a Zend Framework application this eats up. Creating a whole extra dispatch must be a bad idea, even the Zend Framework Performance Guide notes this fact."
This quote is from this article that explains why you should avoid it and what are the alternatives, why I believe to be the purpose of your question.
Maybe action helper or controller plugin using this method:
if ($condition) {
$this->getRequest()
->setModuleName('mymodule')
->setContollerName('mycontroller')
->setActionName('myaction');
// ->setDispatched(false); // redirect
}
Or controller plugin changing layout, using suitable view helpers.
精彩评论