我不确定我是否以正确的方式做这件事。我的目标是在我的布局中显示标题部分的登录或导航。
我的实现看起来像这样(没有逻辑):
2 布局脚本:
- 登录.phtml
- 导航.phtml
FrontController 插件:
class Plugin_Header extends Zend_Controller_Plugin_Abstract {
/**
* PreDispatch
*
* Decides wich kind of navigation is displayed in header section
* for logged in users the menu, for guests the login box and
* link to registration form.
*
* @return void
*/
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$layout = Zend_Layout::getMvcInstance();
$layout->topNavigation = $layout->render('login'); // or navigation
}
}
它工作正常,但这是最好的方法吗?;)