/**
  * Change template if Mega Menu is enabled
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (Mage::helper('megamenu')->isMegaMenuEnabled()) {
         $this->setTemplate('megamenu/page/html/megamenu.phtml');
     }
     return parent::_toHtml();
 }
Exemple #2
0
 protected function _toHtml()
 {
     if (!Mage::helper('jmmegamenu')->get('show')) {
         return parent::_toHtml();
     }
     //bind data vars if has
     $attributes = get_object_vars($this->megaHelper->params);
     foreach ($attributes as $key => $value) {
         $data = $this->getData($key);
         if ($data) {
             $attributes[$key] = $data;
         }
     }
     $this->megaHelper->setParams($attributes);
     //set template
     $this->setTemplate("joomlart/jmmegamenu/output.phtml");
     //get menu group id
     $menu_key = isset($this->megaHelper->params->menu_key) && $this->megaHelper->params->menu_key ? $this->megaHelper->params->menu_key : null;
     $menu_group_id = Mage::helper('jmmegamenu')->getMenuId($menu_key);
     $this->megaHelper->setParams(array('menu_group_id' => $menu_group_id));
     if ($menu_group_id) {
         //get menu items
         $collections = Mage::getModel('jmmegamenu/jmmegamenu')->getCollection()->setOrder("parent", "ASC")->setOrder("ordering", "ASC")->addFilter("status", 1, "eq")->addFilter("menugroup", $menu_group_id);
         //built menu tree
         $tree = array();
         foreach ($collections as $collection) {
             $collection->tree = array();
             $parent_tree = array();
             if (isset($tree[$collection->parent])) {
                 $parent_tree = $tree[$collection->parent];
             }
             //Create tree
             array_push($parent_tree, $collection->menu_id);
             $tree[$collection->menu_id] = $parent_tree;
             $collection->tree = $parent_tree;
         }
         $this->megaHelper->getList($collections);
         ob_start();
         $this->megaHelper->genMenu();
         $output = ob_get_contents();
         $this->assign('menuoutput', $output);
         ob_end_clean();
     } else {
         echo Mage::helper('jmmegamenu')->__('There are not menu items found.');
     }
     return parent::_toHtml();
 }
 protected function _toHtml()
 {
     if (!Mage::helper('jmmegamenu')->get('show')) {
         return parent::_toHtml();
     }
     //set template
     $this->setTemplate("joomlart/jmmegamenu/output.phtml");
     //get menu id
     $menuType = $this->getData('menu_type');
     $this->menu->menu_type = $menuType;
     $menuId = Mage::helper('jmmegamenu')->getMenuId($menuType);
     if ($menuId) {
         //get menu items
         $collections = Mage::getModel('jmmegamenu/jmmegamenu')->getCollection()->setOrder("parent", "ASC")->setOrder("ordering", "ASC")->addFilter("status", 1, "eq")->addFilter("menugroup", $menuId);
         //built menu tree
         $tree = array();
         foreach ($collections as $collection) {
             $collection->tree = array();
             $parent_tree = array();
             if (isset($tree[$collection->parent])) {
                 $parent_tree = $tree[$collection->parent];
             }
             //Create tree
             array_push($parent_tree, $collection->menu_id);
             $tree[$collection->menu_id] = $parent_tree;
             $collection->tree = $parent_tree;
         }
         $this->menu->getList($collections);
         ob_start();
         $this->menu->genMenu();
         $menuoutput = ob_get_contents();
         $this->assign('menuoutput', $menuoutput);
         ob_end_clean();
     } else {
         echo Mage::helper('jmmegamenu')->__('Menu items not found.');
     }
     return parent::_toHtml();
 }
 public function _toHtml()
 {
     if (!Mage::helper('jmmegamenu')->get('show')) {
         return parent::_toHtml();
     }
     $this->setTemplate("joomlart/jmmegamenu/output.phtml");
     $storeid = Mage::app()->getStore()->getStoreId();
     $resource = Mage::getSingleton('core/resource');
     $read = $resource->getConnection('core_read');
     $menutable = $resource->getTableName('jmmegamenu_store_menugroup');
     $query = 'SELECT menugroupid ' . ' FROM ' . $menutable . ' WHERE store_id = ' . (int) $storeid . ' ORDER BY id';
     $rows = $read->fetchRow($query);
     if (!$rows["menugroupid"]) {
         $rows["menugroupid"] = 0;
     }
     $collections = Mage::getModel('jmmegamenu/jmmegamenu')->getCollection()->setOrder("parent", "ASC")->setOrder("ordering", "ASC")->addFilter("status", 1, "eq")->addFilter("menugroup", $rows["menugroupid"]);
     $tree = array();
     foreach ($collections as $collection) {
         $collection->tree = array();
         $parent_tree = array();
         if (isset($tree[$collection->parent])) {
             $parent_tree = $tree[$collection->parent];
         }
         //Create tree
         array_push($parent_tree, $collection->menu_id);
         $tree[$collection->menu_id] = $parent_tree;
         $collection->tree = $parent_tree;
     }
     $this->menu->getList($collections);
     //$this->menu->genMenu();
     ob_start();
     $this->menu->genMenu();
     $menuoutput = ob_get_contents();
     $this->assign('menuoutput', $menuoutput);
     ob_end_clean();
     return parent::_toHtml();
 }
Exemple #5
0
 /**
  * Return the menu HTML
  *
  * @return string
  */
 protected function _toHtml()
 {
     if (!$this->getTemplate()) {
         if ($this->_beforeToHtml() === false) {
             return '';
         }
         return $this->getMenuHtml();
     }
     return parent::_toHtml();
 }
Exemple #6
0
 protected function _toHtml()
 {
     if (!Mage::helper('jmmegamenu')->get('show')) {
         return parent::_toHtml();
     }
     //bind data vars if has
     $attributes = get_object_vars($this->megaHelper->params);
     foreach ($attributes as $key => $value) {
         $data = $this->getData($key);
         if ($data) {
             $attributes[$key] = $data;
         }
     }
     $this->megaHelper->setParams($attributes);
     //set template
     $this->setTemplate("joomlart/jmmegamenu/output.phtml");
     $menuKey = isset($this->megaHelper->params->menu_key) && $this->megaHelper->params->menu_key ? $this->megaHelper->params->menu_key : null;
     //get cache status
     $cacheType = 'wavethemes_jmmegamenu';
     $useCache = Mage::app()->useCache($cacheType);
     //get menu group id
     $cacheId = $this->getMenuGroupCacheId();
     $cacheContent = Mage::app()->loadCache($cacheId);
     if ($useCache && $cacheContent) {
         $menuGroupId = $cacheContent;
     } else {
         $menuGroupId = Mage::helper('jmmegamenu')->getMenuId($menuKey);
         if ($useCache) {
             try {
                 $tags = array(self::CACHE_TAG);
                 $lifeTime = Mage::getStoreConfig('core/cache/lifetime') ? Mage::getStoreConfig('core/cache/lifetime') : $this->cacheLifeTime;
                 Mage::app()->saveCache($menuGroupId, $cacheId, $tags, $lifeTime);
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     $this->megaHelper->setParams(array('menu_group_id' => $menuGroupId));
     if ($menuGroupId) {
         $cacheId = md5("jmmegamenu_{$menuGroupId}_html_items");
         $cacheContent = Mage::app()->loadCache($cacheId);
         if ($useCache && $cacheContent) {
             $output = unserialize($cacheContent);
         } else {
             $output = $this->_generateMenuHtml($menuGroupId);
             if ($useCache) {
                 try {
                     $tags = array(self::CACHE_TAG);
                     $lifeTime = Mage::getStoreConfig('core/cache/lifetime') ? Mage::getStoreConfig('core/cache/lifetime') : $this->cacheLifeTime;
                     $cacheContent = serialize($output);
                     Mage::app()->saveCache($cacheContent, $cacheId, $tags, $lifeTime);
                 } catch (Exception $e) {
                     Mage::logException($e);
                 }
             }
         }
         $this->assign('menuoutput', $output);
     } else {
         echo Mage::helper('jmmegamenu')->__('There are not menu items found.');
     }
     return parent::_toHtml();
 }