I want to show banner only on home page. I am using $this->getIsHomePage() in header.phtml from my theme. I have also created store views for multiple languages. But when i change store view on home page $this->getIsHomePage() condition returns false.
I think its due to change in url like this. /magento/?___store=french&___from_store=default How to resolve this issue?

4 Answers 4


getIsHomePage has a bug in it. It does not return true if you have get parameters in it.
For example if you cal it in example.com/?a=1 it will return false.
Instead of getIsHomepage use this:

$action = Mage::app()->getFrontController()->getAction()->getFullActionName();
if ($action == 'cms_index_index') {
    //your are on the homepage
else {
    //not on homepage

You can use this method anywhere, without having to access the header block.

    $is_homepage = Mage::getBlockSingleton('page/html_header')->getIsHomePage();
        echo 'homepage';
        echo 'not homepage';

If anybody wants to stick to getIsHomePage function, it can still be used following below steps:

Firstly make a copy of app/code/core/Mage/Page/Block/Html/Header.php to same path from Mage dir in local like app/code/local/Mage/Page/Block/Html/Header.php.

Open the file you just copied in local codepool.

Then go to line that says public function getIsHomePage() or around line no. 51(if the file hasn't already been overriden yet) and replace "getIsHomePage" function with below code:

public function getIsHomePage()
    $homeUrl = $this->getUrl('')
    $currentUrl = $this->getUrl('*/*/*', array('_current'=>true, '_use_rewrite'=>true));
    if (strpos($currentUrl, '?') !== false) $currentUrl = array_shift(explode('?', $currentUrl));
    return $homeUrl == $currentUrl;

So now the getIsHomePage function will ignore parameters starting with ? in url, thus it will work across multiple store views.

Hope this will help someone.

$is_homepage = Mage::getBlockSingleton('page/html_header')->getIsHomePage();
    echo "You are on Homepage!";
} else {
    echo "You are NOT on Homepage!";

Please try this :)

  • I tried it :) Doesn't seem to work with parameters, see accepted answer. Apr 18, 2017 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.