How to check the current page is homepage or not in Magento?

How to check the current page is homepage or not in Magento?

April 21, 2012 In the magento all the pages define by "Identifier". First we will check the current page is a CMS page or not after that we will check the current page identifier is "home" or not. We will check for "home" identifier because by default magento home page identifier be "home" To check the current page is CMS page or  not, we cans use the below code: $page = Mage::app()->getFrontController()->getRequest()->getRouteName();  if ($page == 'cms'): echo "current page is cms page"; Now we will check the cms page identifier using below code: $result=(Mage::getSingleton('cms/page')->getIdentifier()=='home') ? true:false;  If we will merge both code which are above: $result=false; $page = Mage::app()->getFrontController()->getRequest()->getRouteName(); if ($page == 'cms'):     $isnothome=(Mage::getSingleton('cms/page')->getIdentifier()=='home') ? false :true; endif;  <?php if($isnothome) : ?> echo "We are in homepage"; <?php else: ?> echo "It is not a homepage"; <?php endif; ?> Enjoy :)

Related Posts

from my blog


How To Reset Admin Password in Magento

January 20, 2017

As an ecommerce website developer or magento website developer, sometime we  get the a situation when we forget the magento website admin access detail. To reset the password of any...

How to show all attribute after layered navigation filter in Magento

April 10, 2015

Magento Layered Navigation is really good for filter the product but problem is that, if we select any attribute like color or price all other attribute hide which are not...

How to fix layered navigation filer URL in Magento?

April 2, 2015

Magento is really good eCommerce CMS in terms of functionality. Layered Navigation is really good feature of Magento to filter the product in frontend side. Only problem with the layered navigation filter...