getLayout()->getBlock('head')->addCss('magazento/megamenu/'.$skin); if ($skin=='menuredtabs.css') $this->getLayout()->getBlock('head')->addCss('magazento/megamenu/'.$skin); if ($skin=='menublue.css') $this->getLayout()->getBlock('head')->addCss('magazento/megamenu/'.$skin); if ($skin=='menugreen.css') $this->getLayout()->getBlock('head')->addCss('magazento/megamenu/'.$skin); return parent::_prepareLayout(); } public function drawItem($category=0,$item,$class) { $userows =Mage::getStoreConfig('megamenu/options/userows'); // $url=$this->getCategoryUrl($category); $url = Mage::getModel("catalog/category")->load($category->getId())->getUrl(); if ($item['url']!='') $url=$item['url']; $html = '"; return $html; } public function drawCatalog() { $html=''; $data = Mage::getModel('megamenu/data')->getCatalog(); $i=0; foreach ($data as $key => $item) { $i++; $categoryId = $item['catalog_id']; $categoryObject = Mage::getModel('catalog/category')->load($categoryId); $categoryParentId = $categoryObject->getParentId(); foreach (Mage::helper('megamenu/data')->getSubCategories($categoryParentId) as $_category) { if ($_category->getId() == $categoryId) { $class = 'category'.$categoryId; if ($i == 1) $class.= ' first'; if ($i == (count($data))) $class.= ' last'; $html.=$this->drawItem($_category,$item,$class); } } } return $html; } public function array_chunk_fixed($input, $num, $preserve_keys = FALSE) { $count = count($input) ; if($count) $input = array_chunk($input, ceil($count/$num), $preserve_keys) ; $input = array_pad($input, $num, array()) ; return $input ; } public function drawColumnsRows($children,$item) { $col=$item['column']; $rows = count($children) / $col; $chunks = $this->array_chunk_fixed($children, $rows); $helper = Mage::helper('cms'); $processor = $helper->getPageTemplateProcessor(); $html = ''; $html .= ''; return $html; } public function drawColumns($children,$item) { $col=$item['column']; $html = ''; $chunks = $this->array_chunk_fixed($children, $col); $html .= ''; return $html; } public function drawNestedMenus($children, $level=1,$morehref ='') { $moretext=Mage::getStoreConfig('megamenu/options/moretext'); $maxsubcatnum=Mage::getStoreConfig('megamenu/options/maximumsubcat'); $html = ''; return $html; } protected function getActiveChildren($parent) { $activeChildren = array(); if (Mage::helper('catalog/category_flat')->isEnabled()) { $children = $parent->getChildrenNodes(); $childrenCount = count($children); } else { $children = $parent->getChildren(); $childrenCount = count($children); } $hasChildren = $children && $childrenCount; if ($hasChildren) { foreach ($children as $child) { if ($child->getIsActive()) { array_push($activeChildren, $child); } } } return $activeChildren; } public function getCategoryPath($category) { $url = ''; if ($category instanceof Mage_Catalog_Model_Category) { $url = $category->getPathInStore(); $url = strtr($url, ".", "-"); $url = strtr($url, "/", "-"); } else { // do nothing } return $url; } // ----------------------------------------------------------------------------- public function drawAllCategoriesMenu() { $html = ''; $collection =$helper = Mage::helper('catalog/category')->getStoreCategories(); foreach ($collection as $node) { if ($node->getData('level') == 2) { $html .= '
  • '; $url = Mage::getModel("catalog/category")->load($node->getId())->getUrl(); $html .= '' . $node->getData('name') . ''; $html .= '
  • '; } } return $html; } public function drawAdminMenu() { $storeId = Mage::app()->getStore()->getId(); $storeUrl = Mage::getModel('core/store')->load($storeId)->getUrl(); $storeUrl.='#'; $class = ''; $data=Mage::getModel('megamenu/data')->getItems(); $html=''; $i=0; $helper = Mage::helper('cms'); $processor = $helper->getPageTemplateProcessor(); foreach ($data as $item) { $i++; if ($i == (count($data))) $class= ' last'; $url=$storeUrl; if ($item['url']!='') $url=$item['url']; $html .= ''; } return $html; } }