Thursday, 28 June 2012

How to make active css 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>



match Url
 $url1 = Mage::helper('core/url')->getCurrentUrl();

<li  class="<?php if ($url1 == 'http://www.knifedaddy.com/test/shop/brand.html/' ){ ?>active<?php } ?>">
<a href="<?php echo $this->getUrl('shop/brand.html')?>">Brand</a>
</li>

No comments:

Post a Comment

Note: only a member of this blog may post a comment.