0

How can I call footer.phtml only for magento homepage, for rest of the site call footer1.phtml file. I am using magento version:1.9

2

In the footer.phtml template, do the if-else. Put his check on the homepage.

Here is a quick Magento code to check if the current page is homepage or not.

If you are in template/page/html/header.phtml template file, then you can check for homepage with the following code:

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

If you are elsewhere (in any other .phtml template file or in any other .php class file) then you can use the following code:

if(Mage::getBlockSingleton('page/html_header')->getIsHomePage()) {
    echo 'You are in Homepage!';
} else {
    echo 'You are NOT in Homepage!';
}

Below is an alternative way to check for homepage:-

$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!';
}
2
  • thanks for the reply. code works in the local but on the server code didn't work – H_Parekh Jun 20 '18 at 13:18
  • your answer is correct bro.. but some how server's may issue i think – H_Parekh Jun 21 '18 at 6:11
1

You could potentialy do something via the Design tab in CMS > Pages

<reference name="root">
    <remove name="footer" />
    <block type="page/html_footer" name="footer-home" as="footer" template="page/html/footer-home.phtml">
</reference>
2
  • I used your code but not works ... any need to do something extra like in layout file.. – H_Parekh Jun 21 '18 at 5:54
  • use as="footer" instead of as="footer-home" now its works fine +1 from me – H_Parekh Jun 21 '18 at 6:10
0

One way to do that is checking class in body tag, then having the footer1 and footer content in the same template.

Homepage will have class "cms-index-index", based on that you can determine where are you and show/hide content with css. IMO, it may be easier, so you don't need to have logic to check the router which basically is there in body tag.

.cms-index-index .footer-content {
    display: block;
}

.cms-index-index .footer1-content, 
.footer-content {
    display: none;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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