views:

60

answers:

1

Hi, I have my Zend_Navigation loaded from a PHP array (but that's irrelevant...) and I'm using the navigation menu helper to generate a menu based on the loaded navigation. Some menu items must not appear in the outputted menu, so I simply set "'visible' => false" in my array for that page and there you go! But if the URL of an 'hidden' menu is accessed, the findActive($container) view helper method returns an empty array, thus the page from the container is not returned, even if it should (like if the page didn't exist); leaving the browser title empty, etc.

Since both the menu navigation helper and the navigation view helper uses the 'visible' option to discard the page (through the method accept($page)), this setting is useless in my case.

What would be the best way to go from here?

A: 

well, after some tinkering, I finally chose this option:

  1. I have an extra option for the page that I don't want to show in my menu: "menuItem". (this option is not mandatory and may be null/unset)
  2. in my layout's script, I iterate recursively through all the pages and set $page->visible = false; on all pages that false === $page->menuItem is true
  3. I call the menu navigation helper

Since when the menu navigation helper is called only after the view script has been called (headTitle is set), and the check is done in my layout, then I can safely set any page's visible property to false without negative drawbacks.

Yanick Rochon