問(wèn)題描述
我想使用導(dǎo)航助手通過(guò) Acl 構(gòu)建我的導(dǎo)航菜單.我的 Acl 部分工作正常.
I want to use the navigation helper to build my navigation menus using Acl. The Acl part I have working fine.
我現(xiàn)在希望能夠顯示幾種不同類型的導(dǎo)航.例如.admin-nav、side-nav、new-nav 等.我在文檔中找不到任何關(guān)于此的信息.只有如何設(shè)置導(dǎo)航,然后在布局或視圖中重復(fù)使用該導(dǎo)航對(duì)象.
I now want to be able to display a few different types of navigation. E.g. admin-nav, side-nav, new-nav, etc. I cannot find anything about this in the docs. Only how to set the navigation and then use that one navigation object repeatedly within a layout or view.
我嘗試了類似的方法 - 有兩個(gè)不同的容器,具有不同的頁(yè)面數(shù)組,然后在注冊(cè)表中設(shè)置這些容器.然后從我的視圖和/或布局中調(diào)用導(dǎo)航并將其傳遞給一個(gè)容器:
I tried something similar to this - having two different containers, with different arrays of pages, then setting these containers in the registry. Then from within my view and/or layout calling navigation and passing it a container:
<?php echo $this->navigation(Zend_Registry::get("news-nav")) ?>
上面在我的新聞視圖中調(diào)用,下面在我的布局中調(diào)用
The above is called in my news view, the following is called in my layout
<?php echo $this->navigation(Zend_Registry::get("admin-nav")) ?>
這適用于我的所有頁(yè)面,除了新聞頁(yè)面.在我的新聞頁(yè)面上,新聞導(dǎo)航顯示兩次,一次在布局中,一次在新聞視圖中.管理導(dǎo)航從不顯示,似乎被新聞導(dǎo)航覆蓋.
This works fine for all my pages, apart from the news page. On my news page the nav for news is displayed twice, once in the layout and once in the news view. The admin nav is never displayed and seems to be overwritten by the news nav.
我可能會(huì)以完全錯(cuò)誤的方式解決這個(gè)問(wèn)題,如果是這樣,請(qǐng)告訴我更好的方法.如果這個(gè)方法看起來(lái)不錯(cuò),有人能幫我弄清楚為什么在布局和新聞視圖中顯示新聞導(dǎo)航.
I could be going about this completely the wrong way, if so please let me know a better way. If this method seems fine, can someone help me sort out why the news nav is being displayed in the layout and in the news view.
感謝您的時(shí)間
杰克
推薦答案
我遇到了完全相同的問(wèn)題.我只是在我的控制器中為我需要的每個(gè)菜單創(chuàng)建多個(gè) Zend_Navigation_Container 實(shí)例,將它們傳遞給視圖,然后通過(guò)將對(duì)象直接傳遞給菜單渲染方法來(lái)渲染它們.如下:
I have had this exact same issue. I just create multiple instances of Zend_Navigation_Container in my controllers for each of the menus I need, pass them to the view and then render them by passing the objects directly to the menu render method. As follows:
在控制器中:
$this->view->menu1 = new Zend_Navigation_Container();
$this->view->menu2 = new Zend_Navigation_Container();
在視圖中:
$this->navigation()->menu()->renderMenu($this->menu1);
$this->navigation()->menu()->renderMenu($this->menu2);
您甚至可以自定義每一個(gè)(通過(guò)在初始 menu() 調(diào)用后插入方法調(diào)用:
You could even customise each one (by inserting method calls after the initial menu() call:
$this->navigation()->menu()->setUlClass('my_first_menu')->renderMenu($this->menu1);
$this->navigation()->menu()->setUlClass('my_second_menu')->renderMenu($this->menu2);
這篇關(guān)于Zend Framework - 多板導(dǎo)航塊的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!