Search code examples
zend-frameworkzend-navigation

Zend_Navigation hierarchy issue with home page


I'm building a menu and breadcrumbs with Zend_Navigation but have a small problem with the hierarchy of the home page. Here's a basic example of a Zend_Navigation with an XML file.

<config>
    <nav>
        <home>
            <label>Home</label>
            <controller>index</controller>
            <action>index</action>
        </home>

        <about>
            <label>About</label>
            <controller>about</controller>
            <action>index</action>
        </about>

        <contact>
            <label>Contact</label>
            <controller>contact</controller>
            <action>index</action>
        </contact>
    </nav>
</config>

In the menu, the about and contact page should be on the same level as the home page (as shown below). This works as expected, since all of these pages are on the same level in the navigation XML file.

<ul>
    <li>Home</li>
    <li>About</li>
    <li>Contact</li>
</ul>

In the breadcrumbs however, the about and contact page should be nested in the home page. This means that the following breadcrumb should be shown on the about page:

Home > About

How would I be able to achieve this?


Solution

  • You are doing it wrong way. Breadcrumbs shows the hierachy of navigation, so if you do not have "About" and "Contact" under the "Home" page you can't show it this way with breadcrumbs.

    You can build to separe navigation trees for Menu and Breadcrumbs, or dirty workaround with breadcrumbs view modification.