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

How to add new search engine like Solr or Elasticsearch in Magento2

Magento 2 Community Edition comes with support for only MySQL search engine, but some projects …

Leave a Reply

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

4

March 29, 2017

Clear all

Warning: Cannot modify header information - headers already sent by (output started at /home/u797196687/public_html/wp-content/themes/sushil/framework/functions/search-live.php:334) in /home/u797196687/public_html/wp-content/plugins/wppush-push-notifications/WPPush.php on line 274