I am rendering the top-level elements of a Zend Navigation object in one place like this:
echo $this->navigation()->menu()->setMaxDepth(0);
How do I render the navigation tree from the second level on down for the active branch? I've tried creating a partial that loops the $this->container
object, but I don't know how to determine if my current item is the active branch. Once I've determined that it's the active branch how do I render the menu? Am I doing this the hard way and missing something obvious?
Thanks!
UPDATE:
I accepted a solution because that's what I used, but I also would like to provide the answer to my actual question, for reference sake. ($this
is the view object)
// Find the active branch, at a depth of one
$branch = $this->navigation()->findActive($this->nav, 1, 1);
if (0 == count($branch)) {
// no active branch, find the default branch
$pages = $this->nav->findById('default-branch')->getPages();
} else {
$pages = $branch['page']->getPages();
}
$this->subNav = new Zend_Navigation($pages);
$this->subNav
can then be used to render the sub-menu.
If I got your question right, this is how I do it:
Renders only the submenu of currently active menu.
I do it this way:
but this is not a good solution. Better one for each level as a separate menu:
I do something similar. My main navigation is handled with something like this...
Then in my tabs.phtml I iterate over the container like so...
I hope that helps a bit.