我渲染一個Zend導航對象的頂級元素在一個地方是這樣的:渲染Zend的導航活躍的分支沒有頂級
echo $this->navigation()->menu()->setMaxDepth(0);
如何呈現導航樹從第二級上下來的活躍分支?我已經嘗試創建一個部分循環$this->container
對象,但我不知道如何確定我的當前項目是否爲活動分支。一旦我確定它是活動分支我該如何渲染菜單?我是否以這種艱難的方式來做這件事,並且錯過了一些明顯的東西?
謝謝!
UPDATE:
我接受的解決辦法,因爲這是我用過的東西,但我也想提供的答案,我的實際問題,以供參考。 ($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'來自哪裏? – Sejanus 2011-04-01 14:57:53