Ejemplo n.º 1
0
 public function deleteAction()
 {
     $id = $this->_request->getParam('id');
     $mdlMenuItem = new Model_MenuItem();
     $currentMenuItem = $mdlMenuItem->find($id)->current();
     $mdlMenuItem->deleteItem($id);
     $this->_request->setParam('menu', $currentMenuItem->menu_id);
     $this->_forward('index');
 }
Ejemplo n.º 2
0
 public function renderAction()
 {
     $menu = $this->_request->getParam('menu');
     // fetch the Zend_Cache object
     $bootstrap = $this->getInvokeArg('bootstrap');
     $cache = $bootstrap->getResource('cache');
     $cacheKey = 'menu_' . $menu;
     // attempt to load the menu from cache
     $container = $cache->load($cacheKey);
     if (!$container) {
         // if the menu is not cached then build it and cache it
         $mdlMenuItems = new Model_MenuItem();
         $menuItems = $mdlMenuItems->getItemsByMenu($menu);
         if (count($menuItems) > 0) {
             foreach ($menuItems as $item) {
                 // add a cache tag so you can update the menu when you update the items
                 $tags[] = 'menu_item_' . $item->id;
                 $label = $item->label;
                 if (!empty($item->link)) {
                     $uri = $item->link;
                 } else {
                     // add a cache tag to this menu so you can update the cached menu
                     // when you update the page
                     $tags[] = 'page_' . $item->page_id;
                     // update this to form more search engine friendly URLs
                     $page = new CMS_Content_Item_Page($item->page_id);
                     $uri = '/page/open/title/' . $page->name;
                 }
                 $itemArray[] = array('label' => $label, 'uri' => $uri);
             }
             $container = new Zend_Navigation($itemArray);
             // cache the container
             $cache->save($container, $cacheKey, $tags);
         }
     }
     if ($container instanceof Zend_Navigation_Container) {
         $this->view->navigation()->setContainer($container);
     }
 }