views:

377

answers:

1

Hi Guys,

I'm still a relative newcomer to Zend Framework, so please forgive me if this is a stupid question!

I'm using the breadcrumbs view helper in my application's main layout to provide the usual breadcrumb functionality. However I really need the breadcrumbs to contain the parameters passed to the actions that user has clicked on...

So if you click through from "/controller/parent/id/1" to "/controller/child/id/2" the breadcrumb on the child page should link back to "/controller/parent/id/1" rather than just "/controller/parent/"

What are my options? Do I need to build my Zend_Navigation tree with the entire contents of my database, so that every possible ID for every action is catered for? Or can I write my own helper to add the extra parameters to the Zend_Navigation_Page object when the breadcrumbs are rendered?

The first option seems to be the path of least resistance, but feels very inefficient! Although, I suppose this could be done with lazy loading to cut down on memory usage.

Thanks for any help!

Tom

+1  A: 

I think the answer is to use the reset_params inside your navigation.xml

Inside your page you need to set reset_params = 0 like this:

<reset_params>0</reset_params>

See: http://framework.zend.com/manual/en/zend.navigation.pages.html

For example on our application we use something like this:

<config>
<nav>
    <fsms>
        <label>Home</label>
        <module>default</module>
        <controller>index</controller>
        <action>index</action>
        <pages>
   <!-- Cases -->
   <page_case>
    <label>Case</label>
    <module>case</module>
    <controller>details</controller>
    <action>index</action>
    <reset_params>0</reset_params>
    <pages>
     <!-- Case Creation -->
     <page_case_create>
      <label>Creation</label>
      <module>case</module>
      <controller>create</controller>
      <action>index</action>
     </page_case_create>
    </pages>
   </page_case>
  </pages>
 </fsms>
</nav>

Matt Wheeler