Jon Skarpeteig
Jon Skarpeteig

Reputation: 4128

Bootstrapping Zend Layout and include navigation resource

I have a problem with rendering navigation menu when I use the following bootstrap:

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); 
}

In my layout.phtml I have:

echo $this->navigation()->menu();

And in my application.ini I have:

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"

Issuing the $view = $layout->getView(); results in my navigation menu not being rendered. If I comment that part out, it renders fine.

How can I set the title, and acl role in the bootstrap, and still render my menu correctly?

Upvotes: 0

Views: 1073

Answers (1)

Aron Rotteveel
Aron Rotteveel

Reputation: 83193

Have you tried adding the view resource to your application.ini and retrieving your resources directly?

application.ini:

resources.view[] =

Bootstrap:

public function _initViewHelpers()
{
    $this->bootstrap('layout');
    $this->bootstrap('view');
    $this->bootstrap('navigation');
    $layout = $this->getResource('layout');
    $view = $this->getResource('view');
    ....

Upvotes: 1

Related Questions