Thursday 14 November 2013

check current page is category page or another page in Magento

 
Hi In magento sometime we need to place conditions on content on the basis of page type .
For  that the best way to find the current page type is to check the controller of that page,
Below you can see how we can do this


  <?php $category = Mage::app()->getFrontController()->getRequest()->getControllerName(); // gives current controller name for eg "cart", "category"

you can check it by
 echo  $category ;  and than on the basis of that you can place your condition like below

in this i have check two controllers cart and or category thats why i have use array to check there values .
    $catpage = array("cart", "category");
if(in_array($category, $catpage)){    ;?>       

        <?php } else { ?>

<?php }?>

No comments:

Post a Comment