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>  

No comments:

Post a Comment