这是一个自定义的 CMS,菜单列表可以在后端编辑,然后需要在前端布局中显示。
菜单控制器在 - /application/modules/admin/controllers
渲染操作的代码是:
<?php
class Admin_MenuController extends CMS_Controller_AdminbaseController
{
public function renderAction()
{
$menu = $this->_request->getParam('menu');
$mdlMenuItems = new Model_MenuItems();
$menuItems = $mdlMenuItems->getItemsByMenu($menu);
if(count($menuItems)>0){
foreach($menuItems as $item){
$label = $item->label;
if(!empty($item->link)){
$uri = $item->link;
}else{
$uri = '/page/open/id/' . $item->pageId;
}
$itemArray[] = array(
'label' => $label,
'uri' => $uri
);
}
$container = new Zend_Navigation($itemArray);
$this->view->navigation()->setContainer($container);
}
}
}
当在 - /application/modules/admin/views/scripts/menu/render.phtml 中使用
<? echo $this->navigation()->menu(); ?>
它渲染得很好,但我想在/application/layouts/scripts中渲染它。任何帮助深表感谢。