Add Zend_Navigation to the View with old legacy bootstrap

Posted by Grant Collins on Stack Overflow See other posts from Stack Overflow or by Grant Collins
Published on 2010-04-02T15:06:41Z Indexed on 2010/04/02 15:53 UTC
Read the original article Hit count: 415

Hi,

I've been struggling with Zend_Navigation all weekend, and now I have another problem, which I believe has been the cause of a lot of my issues.

I am trying to add Zend_Navigation to a legacy 1.7.6 Zend Framework application, i've updated the Zend Library to 1.9.0 and updated the bootstrap to allow this library update.

The problem is that I don't know how, and the examples show the new bootstrap method of how to add the Navigation object to the view, I've tried this:

//initialise the application layouts with the MVC helpers
$layout = Zend_Layout::startMvc(array('layoutPath' => '../application/layouts'));

$view = $layout->getView();
$configNav = new Zend_Config_Xml('../application/config/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($configNav);
$view->navigation($navigation);
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer();
$viewRenderer->setView($view); 

This seems to run through fine, but when I go to use the breadcrumb view helper in my layout, it errors with: Strict Standards: Creating default object from empty value in C:\www\moobia\development\website\application\modules\employers\controllers\IndexController.php on line 27

This is caused by the following code in the init() function of my controller.

$uri = $this->_request->getPathInfo();
$activeNav = $this->view->navigation()->findByUri($uri); <- this is null when called
$activeNav->active = true;

I believe it's because the Zend_Navigation object is not in the view.

I would look at migrating the bootstrap to the current method, but at present I am running out of time for a release.

Thanks,

Grant

© Stack Overflow or respective owner

Related posts about zend-framework

Related posts about zend-navigation