我正在像这样在一个地方呈现 Zend Navigation 对象的顶级元素:
echo $this->navigation()->menu()->setMaxDepth(0);
如何为事件分支从第二层向下呈现导航树?我已经尝试创建一个循环 $this->container
对象的部分,但我不知道如何确定我的当前项目是否是事件分支。一旦我确定它是事件分支,我该如何呈现菜单?我这样做是不是很费力并且遗漏了一些明显的东西?
谢谢!
更新:
我接受了一个解决方案,因为这是我使用的解决方案,但我也想提供我实际问题的答案,以供引用。 ($this
是 View 对象)
// 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
然后可用于呈现子菜单。
最佳答案
如果我答对了你的问题,我就是这样做的:
print $this->navigation()->menu()->renderMenu(null, array(
'minDepth' => 1,
'maxDepth' => 1,
'onlyActiveBranch' => true,
'renderParents' => false));
仅呈现当前事件菜单的子菜单。
关于php - 在没有顶级的情况下呈现 Zend Navigation 的事件分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3496763/