0

I've got another problem with Zend. I am trying to get Zend_Naviation to work, it seems to be pretty simple but no matter how I implement it i get the same error:

Zend_Navigation_Exception: Bad method call: Unknown method Zend_Navigation::menu in C:\wamp\www\ehu\library\Zend\Navigation\Container.php on line 358

I know there is a method "menu", i've seen it working many times.

I am trying to render this menu in layout, i tried to use View Helper to prepare navigation in PHP as well as config XML file initialized in bootstrap (like below) but neither of them worked.

protected function _initNavigation() 
{

        $this->bootstrap("layout");
        $layout = $this->getResource('layout');
        $view = $layout->getView();

        $config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml','nav');
        $navigation = new Zend_Navigation($config);

        $view->navigation($navigation);

}

EDIT OK, now i know where is the problem - for my webpage i am not using a default layout.phtml but page.html. How to modify the above code to make the menu work in page.phtml? It seems to work fine in the default layout.phtml

bwitkowicz
  • 779
  • 6
  • 15

1 Answers1

0

You have to set the alternative layout you want to use

 $layout = $this->getResource('layout');
 $layout-setLayout('page'); // here you change the layout to use your page.phtml
 $view = $layout->getView();

More information you will find under Using Zend_Layout with the Zend Framework MVC

ByteNudger
  • 1,545
  • 5
  • 29
  • 37