Toggle menu in left navigation magento pages


Put the below code and script file into your phtml file
      <div class="home-block-sider">
    <div class="sider-title">
        <h3>Menu</h3>
    </div>
    <div class="menu-block-content">
    <?php $_helper = Mage::helper('catalog/category') ?>
    <?php $currentCategory = Mage::registry('current_category') ?>
    <?php $_cate = Mage::helper('catalog/category')->getStoreCategories(); ?>
    <?php $i=0; foreach ($_cate as $_category): ?>
    <?php $i++ ?>
        <?php if($_category->hasChildren()): ?>
        <ul class="tabs">
            <li><a title="content_<?php echo $i ?>" class="tab"><?php echo $_category->getName();?></a></li>
     
    
            <ul id="content_<?php echo $i ?>" class="menu-content">
             <?php $_category = Mage::getModel('catalog/category')->load($_category->getId()) ?>
              <?php $_subcategories = $_category->getChildrenCategories() ?>
             
               <?php $i=0; foreach($_subcategories as $_subcategory): ?>
               <? $i++ ?>
                            <li>
                                <a title="content_<?php echo $i ?>" class="tab" href="<?php echo $_helper->getCategoryUrl($_subcategory) ?>">
                                    <?php echo $_subcategory->getName() ?>
                                </a>
                            </li>
                        <?php endforeach; ?>
           
      
              
                </ul>
                
          </ul>
           <?php endif; ?>
       
    <?php endforeach; ?>
    </div>
</div>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
jQuery.noConflict();
jQuery(document).ready(function(){
    jQuery("a.tab").click(function () {
        jQuery(".active").removeClass("active");
        jQuery(this).addClass("active");
        jQuery(".menu-content").slideUp();
        var content_show = jQuery(this).attr("title");
        jQuery("#"+content_show).slideDown();
    });
});

</script>
   
paste the above code

Comments

Post a Comment

Feel Free To Ask...