There are some instances that we need to add scripts, images or snippets in a specific page like “homepage”. In Magento, in order for you to check the current page if you are in home page / index page of your site, the following code work perfectly. 
<?php if(
Mage::getSingleton('cms/page')->getIdentifier() == 'home'  &&
Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms' 
) : ? >
//insert your code here 
<?php endif; ?>
You can also try this one. <?php
if($this->getUrl('') == $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true))):
echo "Homepage";
else:
echo "Not in Homepage";
endif;
?>
4 comments:
God, I feel like I should be taking notes! Great work
Great, exactly what i needed!
Thanks.. I got exactly what I needed..
Thanks mate! Works like charm!
Post a Comment