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 .= '';
$html .= '
';
$html .= $processor->filter($item['content_top']);
$html .= '
';
foreach ($chunks as $chunk) {
$html .= '
';
$items = $this->array_chunk_fixed($chunk, $col);
foreach ($items as $value) {
$html .= '
';
$html .= $this->drawNestedMenus($value, 1);
//$html .= 'key';
$html .= '
';
}
//$html .= 'row';
$html .= '
';
}
$html .= '
';
$html .= $processor->filter($item['content_bottom']);
$html .= '
';
$html .= '
';
return $html;
}
public function drawColumns($children,$item) {
$col=$item['column'];
$html = '';
$chunks = $this->array_chunk_fixed($children, $col);
$html .= '';
$helper = Mage::helper('cms');
$processor = $helper->getPageTemplateProcessor();
$html .= '
';
$html .= $processor->filter($item['content_top']);
$html .= '
';
foreach ($chunks as $key => $value) {
$html .= '
';
$html .= $this->drawNestedMenus($value, 1);
$html .= '
';
}
$html .= '
';
$html .= $processor->filter($item['content_bottom']);
$html .= '
';
$html .= '
';
return $html;
}
public function drawNestedMenus($children, $level=1,$morehref ='') {
$moretext=Mage::getStoreConfig('megamenu/options/moretext');
$maxsubcatnum=Mage::getStoreConfig('megamenu/options/maximumsubcat');
$html = '