<div class="left-category"><?php echo $this-> __('CATEGORIES')?></div> <div class="maincategory"> <?php $_helper = Mage::helper('catalog/category'); $_categories = $_helper->getStoreCategories(); $currentCategory = Mage::registry('current_category') ; $rootCategoryId = Mage::app()->getStore()->getRootCategoryId(); $rootCategory = Mage::getModel('catalog/category')->load($rootCategoryId); $childIds = explode(',',$rootCategory->getChildren()); if (count($childIds) > 0): ?> <?php foreach($childIds as $_category): $_category = Mage::getModel('catalog/category')->load($_category); ?> <div class="maincatdiv"> <div class="catheader"> <span class="category_name"> <a href="<?php echo $_helper->getCategoryUrl($_category) ?>"> <?php echo $_category->getName() ?></a></span> <?php if ($_category->getChildren() != ''){?><span class="caticon">+</span><?php } ?> </div> <div class="catcontent" style="display:none;"><?php if ($_category->getChildren() != ''): $allsubchild = explode(',',$_category->getChildren()); ?> <ul> <?php foreach($allsubchild as $_sub): $_subcategory = Mage::getModel('catalog/category')->load($_sub); ?> <li> <a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>"> <?php echo $_subcategory->getName() ?> </a> </li> <?php endforeach; ?> </ul> <?php endif; ?></div> </div> <?php endforeach; ?> <?php endif; ?> </div> <script type="text/javascript"> jQuery(window).load(function(){ jQuery('.caticon').click(function(){ var str = jQuery(this).closest('.maincatdiv').find('.catcontent').html().split(' '); if(str[0] != '') { if(jQuery(this).attr('class').indexOf('active') != -1) { jQuery('.catcontent').slideUp(); jQuery('.caticon').removeClass('active'); jQuery('.caticon').html('+'); } else{ jQuery('.catcontent').slideUp(); jQuery('.caticon').removeClass('active'); jQuery('.caticon').html('+'); jQuery(this).addClass('active'); jQuery(this).html('-'); jQuery(this).closest('.maincatdiv').find('.catcontent').slideDown(); } } }); }) </script>
Categories: Magento
0 Comments