Wednesday, 5 September 2012

How to make active class in magento

 Make a class in css like .mainmenu li.active a{ color:#f68e1e; }


<li class="home<?php if (Mage::helper('core/url')->getCurrentUrl() === Mage::helper('core/url')->getHomeUrl()):?> active<?php endif;?>"> <a href="<?php echo $this->getUrl('') ?>">  Home </a> </li>
     <li class="<?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'about-us') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . 'about-us' ?>"><?php echo $this->__('About Us')  ?></a>
    </li>
   <li class="<?php if (strpos(Mage::helper('core/url')->getCurrentUrl(),'product') != false ) :?> active<?php endif;?>">
          <a href="<?php echo $this->getUrl('') . 'product' ?>"><?php echo $this->__('Product')  ?></a>
    </li>



<?php if (strpos($_SERVER['REQUEST_URI'],'index') != false )
  {
  echo 'active';
  } ?>

No comments: