0
votes

simple question.

I've got a navigation that is being rendered from the database. I want to use it in two different layouts - one for default module (layout is "page.phtml") and one for admin module (this one is "layout.phtml").

I'm setting up Zend_Navigation like this:

    $structure = new Application_Model_DbTable_Pages();     
    $pages_ready = $structure->getPagesNavigation();
    $container = new Zend_Navigation($pages_ready);
    Zend_Registry::set('Zend_Navigation', $container);

And calling it like this:

<?php echo $this->navigation()->adminNav(); ?> //custom helper adminNav

Problem is - it only works in the layout.phtml file (or any admin-module view that uses this layout). In the other layout it throws

Fatal error: Uncaught exception 'Zend_Navigation_Exception' with message 'Bad method call: Unknown method Zend_Navigation::menu' in C:\wamp\www\ehu\library\Zend\Navigation\Container.php on line 358

How do I get this to work in all layouts?

1

1 Answers

0
votes

I found a walkaround.

Insted of calling

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

in my custom layout file I first initialize view

$view = new Zend_View();

And than call my menu like this

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

Works like a charm for me.