Engine23
blogBannerImage
By Engine23

Magento - How to tell if you are on the home page or not

How to tell if your on the home page in magento or not
if($this->getIsHomePage()) {
echo 'You are in Homepage!';
} else {
echo 'You are NOT in Homepage!';
}

Or you can try this:

$routeName = Mage::app()->getRequest()->getRouteName(); $identifier = Mage::getSingleton('cms/page')->getIdentifier(); if($routeName == 'cms' && $identifier == 'home') { echo 'You are in Homepage!'; } else { echo 'You are NOT in Homepage!'; }