views:

402

answers:

1

I have all the menu items in a Zend Navigation Container. I'm displaying the breadcrumb via Zend's breadcrumb helper.

When I visit one of the menu items, it's displaying the breadcrumb correctly. However, if I have a page which doesn't occur in the Navigation Container, it doesn't show a breadcrumb, which makes sense. But I do want to show a breadcrumb on some of those pages.

I have a controller named "cart" and an action named "checkout". When I visit the page /cart/checkout, I do want to show a breadcrumb. But what's the best way of doing this? Can I manually add breadcrumblinks in de controller or do I have to add the page to the Navigation Container?

+3  A: 

There are three possibilities:

  • add the required paged statically to your navigation container (through code or a configuration file)
  • add the required pages dynamically to your navigation container; either in the action method itself, in the controller-init()-method or via a front-controller-plugin
  • create a separate navigation container with just the pages required by the breadcrumb and pass this container to the breadcrumb-helper (bypassing the automatic container-recovery using the registry).
Stefan Gehrig
I'd go with the first option - add an MVC type page.
David Caunt
Adding pages to the navigation does work, but this also adds the items to the menu. Is there a easy way to prevent these items to be displayed in the menu?
sander
Using different navigation containers is the way to go if you don't want your main navigation to be influenced. Alternatively you can use custom properties on your pages and exclude pages with this special property from the menu-generation (requires you to use custom templates).
Stefan Gehrig