Zend_Navigation rendering submenu

1.9k views Asked by At

I have the following Zend_Navigation config

-Item1
-Item2
   |---SubItem2 1
   |---SubItem2 2
   |---SubItem2 3 (Visible = false)
-Item3
   |---SubItem3 1
   |---SubItem3 2
-Item4
   |---SubItem4 1

Now, in application, whenever the user is on SubItems (visible = true), the submenu renders correctly. But whenever the user is on invisibale page like "SubItem2 3". The submenu does not render.

I can render the breadcrumbs by doing setRenderInvisible() and it works.

I was not able to render the submenu.

Following is the code I use to render the menu and sub-menu.

It is in the layout file.

           <div id="top-nav-menu">
           <?php echo $this->navigation()->menu()->setMaxDepth(0)->setUlClass('topNav'); ?>
       </div>
       <div class="clear"></div>

       <div id="sub-nav-menu">
            <?php echo $this->navigation()->menu()->setMaxDepth(1)->setMinDepth(1)->setOnlyActiveBranch(true)->setUlClass('subNav') ; ?>
            <p style="display:inline;">&nbsp;</p>
       </div>

Any information/pointers are appreciated.

Thanks,

1

There are 1 answers

0
panxpress On

Alright, was able to resolve this with some information from another questions: Zend_Navigation with hidden Pages

The main issue was that when visible = false, there was no active page. As a result of this, no menu items were rendered. So now in a controller helper, apart from what is suggested in the other thread, I also check if any page is active. If no page is active, I set the default page as active and menu renders fine.

Hope this helps someone. Thanks!