Thursday 14 November 2013

highlight current category link in magento

Hi with the below peace of code you can highlight the current category link. In this we get first get the current url and than match it with the category url and on the basis of that we will apply our classes  


 <?php $curr =  "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; //full current url
                                    $currcate =  $category->getURL(); // your category url (i have use this  on product list page )
                                    if ($curr == $currcate) {
                                    $class = "active";}else {

                                    $class="nonactive";}
                                    //echo $class;

                                    ?>
                            
on the bais of above match we will apply alss in the anchor tag as below
<a class="<?php echo $class; ?> " href="<?php echo $category->getURL()?>">




No comments:

Post a Comment