0

使用以下引导程序时,我在渲染导航菜单时遇到问题:

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 角色,并且仍然正确呈现我的菜单?

4

1 回答 1

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');
    ....
于 2011-06-12T11:08:34.393 回答