I am using Zend Framework 1.10.8.
I want to create a breadcrumb section in my layout.phtml. There are some links in my menu that have dynamic url parameters like http://mydomain.com/editor/edit/id/42
I try to figure out how to pass id=XXX to Zend_Navigation, while XXX comes from the database and is different in every request.
One solution I found so far is adding a property e.g. params_id to my xml declaration:
in configs/navigation.xml
<pages>
<editor>
<label>Editor</label>
<controller>editor</controller>
<action>edit</action>
<params_id>id</params_id>
<route>default</route>
</editor>
</pages>
and in the controller looping through the pages and dynamically adding my parameter id = 42 (while 42 would be retrieved from the request object in the final version)
$pages = $this->view->navigation()->getContainer()->findAllBy('params_id','id');
foreach ($pages as &$page) {
$page->setParams(array(
'id' => 42,
'something_else' => 667
));
}
As adding dynamic url parameters seems such a basic requirement for Zend_Navigation I am quite sure that my solution is too complicate, too expensive and there must be a much simplier solution "out of the box".
It is very simple. Just write in your XML
Here is example to do it dynamically based on database data
First define Navigation loading plugin. Name the file Navigation.php and place it in application/plugins/ directory. Here's an example of such plugin:
Then in you Bootstrap init this plugin
An update: I finally ended up throwing away the xml file. What I do now: