Showing posts with label How to create Custom Menu in magento with active class. Show all posts
Showing posts with label How to create Custom Menu in magento with active class. Show all posts

Friday, March 29, 2019

create a custom menu and add active class on it according category.


 <?php
 $main_cat = explode('index.php',$this->helper('core/url')->getCurrentUrl());
 $mn_cat = explode('/',substr($main_cat[1],0,-5));
 $_subcategories = $_category->getChildrenCategories();
?>

<li class="<?php if(in_array(str_replace(' ','-',strtolower($_category->getName())),$mn_cat)){ echo "active";}?>"  >
<span><a href="<?php echo $_helper->getCategoryUrl($_category) ?>"> </span></li>