views:

152

answers:

2

Hey, I have got the Zend navigation in in navigation.xml which is like this:

<nav>
    <home>
        <label>Home</label>
        <controller>index</controller>
        <resource>index</resource>
        <action>index</action>
        <pages>
            <Reports>
                <label>Reports</label>
                    <controller>Reports</controller>
                    <resource>Reports</resource>
                    <action>index</action>
            </Reports>
        </pages>
    </home>
</nav>

and I have initialized my breadcrumbs through

$this->navigation()->breadcrumbs()

That works fine as far as the page is in the navigation.xml but what I want is, for example there is a Report with the name of "Today Report" then the breadcrumb should look like: Home > Reports > Today's Report , in other words dynamic breadcrumbs, is there already a way of doing that? or should I implement my own? should I ditch XML and should use the array for navigation which is then all built dynamically from database and then store the object into registry? but then again I do not want all that to appear in navigation, it should be only for breadcrumbs. Any thoughts?

+1  A: 

You'll need to change your xml to the following:

<nav>
    <home>
        <label>Home</label>
        <controller>index</controller>
        <resource>index</resource>
        <action>index</action>
        <pages>
            <Reports>
                <label>Reports</label>
                <controller>Reports</controller>
                <resource>Reports</resource>
                <action>index</action>
                <pages>
                    <TodayReport>
                        <label>Today Report</label>
                        <controller>Reports</controller>
                        <action>today-report</action>
                                            <visible>0</visible>
                    </TodayReport>
                </pages>
            </Reports>
        </pages>
    </home> </nav>

The Today report will be hidden due (0), but to enable them for the breadcrumbs use the following: $this->navigation()->breadcrumbs()->setRenderInvisible(TRUE);

You can generate a navigation object from the database, this is not explained itself in the documentation but you can find out how to create a navigation object their. http://framework.zend.com/manual/en/zend.navigation.pages.html

Skelton
A: 

If it is just about the breadcrumbs, not the sitemap, do not render the last element and use the title, you are probably already displaying on the page:

<?= $this->navigation()->breadcrumbs()->setMinDepth(0) . ' > ' . $this->title ?>

Otherwise, you have to iterate the container and perform replace manually.

takeshin