views:

102

answers:

3

Hello.. I am experimenting with Zend_Navigation to build breadcrumb for a web site. I created an XML file which lists the hierarchy of pages. Things are working fine for the most part except for pages that have dynamic parameters.

For example, there is a group page which has the URL " www.../groups/gid/1001". The id 1001 is dynamic so it changes for different groups. Because of that I cannot put it in the XML file. In that case, ZF generates a link without including any parameters, which of course won't work.

One solution I found is dynamically injecting the parameters to the Zend_Navigation object. This is working fine except that I need to do it for each action or controller.

Is there a better way to handle it? Does ZF have any classes to do this work?

I will appreciate any feedback.

Thanks!

A: 

I have a similar problem

Brecht Billiet
A: 

At which point do you know the group ID to use in the navigation?

If it's early enough, you could simply create your own bootstrap init method to insert the navigation item, just remember to call $this->bootstrap('navigation') at the top of your method, eg

protected function _initCustomNav()
{
    $this->bootstrap('navigation');
    $navigation = $this->getResource('navigation');

    // add custom item

    return $navigation;
}

Disclaimer: I'm pretty sure the navigation resource is just called 'navigation'

Phil Brown