cancel
Showing results for 
Search instead for 
Did you mean: 

Home Page showing as inside page

Home Page showing as inside page

Hi,

We are facing some issues on applying condition to the inside page of the website. When we use this condition:

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

The result is home page is mostly displaying 'You are NOT in Homepage!'. Few times displays 'You are in Homepage!'. I tried clearing the cache in Magento but it does not help.

Same problem with:

if(Mage::getBlockSingleton('page/html_header')->getIsHomePage())

Best regards,
-Renuka

1 REPLY

Re: Home Page showing as inside page

Hi @Renuka_dev,



Could you please try this alternative method?

 

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

 

 

Best regards.

Gabriel

If my answer was useful, please give "Kudos" to this post.
If my answer helps you to resolve the problem, click on "Accept as Solution".