【发布时间】:2010-08-16 19:48:47
【问题描述】:
我在一个地方渲染 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 然后可以用于渲染子菜单。
【问题讨论】:
-
$branch['pages'] 中的索引“pages”从何而来?
标签: php zend-framework zend-navigation