Give Active class to current category in magento

Here is the code follow it:
  <?php
           $class = '';
        if (Mage::getSingleton('catalog/layer')->getCurrentCategory()->getId() == $category->getId())
        {
            $class = ' class="active"';
        }
        echo '<li'.$class.'><a href="'.$cate.'">'.$category->getName().'</a></li>';
 ?>

Thanks!
Magento Group

Comments