我在一个地方渲染 Zend Navigation 对象的顶级元素,如下所示:
echo $this->navigation()->menu()->setMaxDepth(0);
如何为活动分支从第二级向下渲染导航树?我尝试创建一个循环$this->container
对象的部分,但我不知道如何确定我的当前项目是否是活动分支。一旦我确定它是活动分支,我该如何呈现菜单?我是否以艰难的方式做到这一点并且遗漏了一些明显的东西?
谢谢!
更新:
我接受了一个解决方案,因为这就是我使用的解决方案,但我也想为我的实际问题提供答案,以供参考。($this
是视图对象)
// 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
然后可以用来渲染子菜单。