sander
sander

Reputation: 3

Manually setting a breadcrumb in Zend Framework

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?

Upvotes: 0

Views: 1393

Answers (1)

Stefan Gehrig
Stefan Gehrig

Reputation: 83672

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).

Upvotes: 4

Related Questions