Home / Magento / Magento: How to check if current page is homepage?

Magento: How to check if current page is homepage?

1.)

getIdentifier() == 'home'  &&

Mage::app()->getFrontController()->getRequest()->getRouteName() == 'cms'

) : 
?>
// Put your homepage-only code in here.



2.)

if($this->getIsHomePage()) {
 echo 'You are in Homepage!';
} 
else {
 echo 'You are NOT in Homepage!';
}


3.)

$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!';}

About Sushil_kumar

Check Also

magento-coding-recommendations-to-optimize-site-performance

How to optimize magento code?

How to optimize magento code The code influences the speed of your site. The testing …

Leave a Reply

Your email address will not be published. Required fields are marked *

0

January 24, 2017

Clear all