Zend:在布局中显示管理模块中菜单控制器生成的内容

This is a custom CMS where menu list can be edited in backend and then need to be displayed in front end layout.

Menu controller is in -/application/modules/admin/controllers

and the code for render action is :

<?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);

        } 
    }
}

When rendered in - /application/modules/admin/views/scripts/menu/render.phtml using

<? echo $this->navigation()->menu(); ?>

it renders fine, but instead I want to render it in /application/layouts/scripts. Any help is much appreciated.

go to Zend_View_Helper create exapmle.php as an example;

on it insert function

 public function abc()
{
//insert your code here
}

then go to layout.phtml and call it

echo $this->abc(); 

You can render it in layout this way <?= $this->action('render', 'menu', 'admin');?> Additionally you can pass some parametrs in array. Hope this helps you.