使用以下引导程序时,我在渲染导航菜单时遇到问题:
public function _initViewHelpers()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView(); // Never inits navigation resource?
$view->headTitle()->setSeparator(' - ')
->headTitle('Test');
$role = ($this->_auth->getStorage()->read() === null) ? 'guest' : $this->_auth->getStorage()->read()->role;
$view->navigation()->setAcl($this->_acl)->setRole($role);
}
在layout.phtml
我有:
echo $this->navigation()->menu();
在application.ini
我有:
resources.navigation.pages.index.label = "Home"
resources.navigation.pages.index.title = "Go Home"
resources.navigation.pages.index.controller = "index"
resources.navigation.pages.index.action = "index"
resources.navigation.pages.index.order = -100
resources.navigation.pages.index.route = "default"
在我的导航菜单中发出$view = $layout->getView();
结果未呈现。如果我对该部分进行评论,它就会很好。
如何在引导程序中设置标题和acl角色,并仍能正确呈现我的菜单?
答案 0 :(得分:1)
您是否尝试过将视图资源添加到application.ini
并直接检索资源?
application.ini
:
resources.view[] =
自举:
public function _initViewHelpers()
{
$this->bootstrap('layout');
$this->bootstrap('view');
$this->bootstrap('navigation');
$layout = $this->getResource('layout');
$view = $this->getResource('view');
....