<div class="left-category"><?php echo $this-> __('CATEGORIES')?></div>
<div class="maincategory">
<?php
 
$_helper = Mage::helper('catalog/category');
$_categories = Mage::getResourceModel('catalog/category_collection')
    ->addAttributeToSelect('*')
    ->addAttributeToFilter('is_active', 1) //only active categories
    ->addAttributeToFilter('include_in_menu', 0);
$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">
<?php if (!$_category->getIncludeInMenu()) { ?>
<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><?php }?>
<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>
 <?php if (!$_category->getIncludeInMenu()) { ?>
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?>
</a>
<?php }?>
</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

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *