<div class="block block-list block-categories">
<div id="block-categories" class="block-title active">
<strong><span>Categories </span></strong>
</div>
<div id="leftnav" class="block-content">
<?php $_helper = Mage::helper('catalog/category') ?>
<?php $_categories = $_helper->getStoreCategories() ?>
<?php $currentCategory = Mage::registry('current_category') ?>
<?php if (count($_categories) > 0): ?>
<ul id="menu" class="category-menu">
<?php foreach($_categories as $_category): ?>
<li class="sub <?php if ($this->isCategoryActive($_category)): ?> active<?php endif; ?>">
<a href="<?php echo $_helper->getCategoryUrl($_category) ?>"><?php echo $_category->getName() ?></a>
<?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
<?php $_subcategories = $_category->getChildrenCategories() ?>
<?php if (count($_subcategories) > 0): ?>
<span class="level1-plus">+</span>
<ul>
<?php foreach($_subcategories as $_subcategory): ?>
<li class="<?php if ($this->isCategoryActive($_subcategory)): ?> active<?php endif; ?>">
<a href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
<?php echo $_subcategory->getName() ?></a>
<!--sub sub category-->
<?php $_subcategory = Mage::getModel('catalog/category')->load($_subcategory->getId()) ?>
<?php $_subsubcategories = $_subcategory->getChildrenCategories() ?>
<?php if (count($_subsubcategories) > 0): ?>
<span class="level2-plus">+</span>
<ul>
<?php foreach($_subsubcategories as $_subsubcategory): ?>
<li class="<?php if ($this->isCategoryActive($_subsubcategory)): ?> active<?php endif; ?>">
<a href="<?php echo $_helper->getCategoryUrl($_subsubcategory) ?>">
<?php echo $_subsubcategory->getName() ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
<!--sub sub category-->
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php endif; ?>
</div>
</div>
<script>
jQuery(document).ready(function($){
$('.category-menu span.level1-plus').click(function(e){
$current =$(this).parent().find('> ul');
$('.category-menu .level1-plus').html('+');
if($current.is(':visible')){
$('.category-menu li > ul').slideUp();
}else{
$('.category-menu li > ul').slideUp();
$current.slideDown();
$current.parent().find('.level1-plus').html('-');
}
e.stopPropagation();
});
$('.category-menu span.level2-plus').click(function(e){
$current =$(this).parent().find('> ul');
$('.category-menu .level2-plus').html('+');
if($current.is(':visible')){
$('.category-menu li li > ul').slideUp();
}else{
$('.category-menu li li > ul').slideUp();
$current.slideDown();
$current.parent().find('.level2-plus').html('-');
}
e.stopPropagation();
});
$('.category-menu li.active > ul').slideDown();
if($('.category-menu li').hasClass('active')){
$('.category-menu li.active').find(".level1-plus").html("-");
}
$('.category-menu li li.active').parent().slideDown();
if($('.category-menu li li').hasClass('active')){
$('.category-menu li li.active').parent().parent().find(".category-plus").html("-");
$('.category-menu li li.active').find(".level2-plus").html("-");
}
});
</script>
<style>
.block-categories ul ul{
display: none;
}
</style>