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

Magento: How to check if current page is homepage?

1.)


// 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 admin

Check Also

How to display CMS block in Magento 2 Checkout

Working with CMS blocks was one of the reasons Magento was and is so popular. …

Leave a Reply

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