1

My site Header is not showing in other pages except the Homepage

My Header.phtml Code -

(AFL 3.0)
 */
/**
 * @var Mage_Page_Block_Html_Header $this
 */
?>
<div class="header-container">
<div class="header">
    <?php if ($this->getIsHomePage()):?>
    <h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
    <?php else:?>
    <a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
    <?php endif?>
    <div class="quick-access">
        <?php echo $this->getChildHtml('topSearch') ?>
        <p class="welcome-msg"><?php echo $this->getChildHtml('welcome') ?> <?php echo $this->getAdditionalHtml() ?></p>
        <?php echo $this->getChildHtml('topLinks') ?>
        <?php echo $this->getChildHtml('store_language') ?>
    </div>
    <?php echo $this->getChildHtml('topContainer'); ?>
</div>
</div>
<?php echo $this->getChildHtml('topMenu') ?>

1Column Code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
<head>
<?php echo $this->getChildHtml('head') ?>
</head>
<body<?php echo $this->getBodyClass()?' class="'.$this->getBodyClass().'"':'' ?>>
<?php echo $this->getChildHtml('after_body_start') ?>
<div class="wrapper">
    <?php echo $this->getChildHtml('global_notices') ?>
    <div class="page">
        <?php echo $this->getChildHtml('header') ?>
        <div class="main-container col1-layout">
            <div class="main">
                <?php echo $this->getChildHtml('breadcrumbs') ?>
                <div class="col-main">
                    <?php echo $this->getChildHtml('global_messages') ?>
                    <?php echo $this->getChildHtml('content') ?>
                </div>
            </div>
        </div>
        <?php echo $this->getChildHtml('footer') ?>
        <?php echo $this->getChildHtml('global_cookie_notice') ?>
        <?php echo $this->getChildHtml('before_body_end') ?>
    </div>
</div>
<?php echo $this->getAbsoluteFooter() ?>
</body>
</html>
2
  • 1
    Assuming your homepage as 1column, can you share the code inside 1column.phtml. Also, check in page.xml and local.xml files if there is any condition to remove header from non-Homepages.
    – Prateek
    Commented Dec 22, 2015 at 14:40
  • @Prateek - I have added the code for 1column.phtml . I did check my page.xml file (Nothing Specific) and was not able to find local.xml file
    – Karan
    Commented Dec 22, 2015 at 18:58

2 Answers 2

0
<?php // if ($this->getIsHomePage()):?>
<h1 class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a></h1>
<?php /*else:?>
<a href="<?php echo $this->getUrl('') ?>" title="<?php echo $this->getLogoAlt() ?>" class="logo"><strong><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $this->getLogoSrc() ?>" alt="<?php echo $this->getLogoAlt() ?>" /></a>
<?php endif */?>

Replace above code in your Header.phtml file. This removes the condition to get the same header in all the pages.

5
  • This is not valid solution
    – Abdul
    Commented Dec 22, 2015 at 9:08
  • @Abdul: this the shortest solution for above question. Commented Dec 22, 2015 at 9:39
  • I want my header to show on all pages. Is this the best solution?
    – Karan
    Commented Dec 22, 2015 at 9:59
  • @Karan You can try it, may be for you, it could be the best one. Commented Dec 22, 2015 at 10:10
  • @MuhammadFayyaz-Ud-DinKhattak - It didn't help. I still cannot see my header in other pages
    – Karan
    Commented Dec 22, 2015 at 10:20
0

Your code is good the header should be displayed in all the pages according to the native behavior of Magento, so the issue probably comes from some xml you may have to change some tag that make the display is restricted only to the homepage or some extension elsewhere !

In the solution that I give you, I recreate the header block again.

Go to : app/design/frontend/{yourpackage}/{yourtheme}/layout/local.xml then add this block between <default>...here...</default> like this:

<default>
    <reference name="root">
        <block type="page/html_header" name="header" as="header">
            <block type="page/template_links" name="top.links" as="topLinks"/>
            <block type="page/switch" name="store_language" as="store_language" template="page/switch/languages.phtml"/>
            <block type="core/text_list" name="top.menu" as="topMenu" translate="label">
                <label>Navigation Bar</label>
                <block type="page/html_topmenu" name="catalog.topnav" template="page/html/topmenu.phtml"/>
            </block>
            <block type="page/html_wrapper" name="top.container" as="topContainer" translate="label">
                <label>Page Header</label>
                <action method="setElementClass"><value>top-container</value></action>
            </block>
            <block type="page/html_welcome" name="welcome" as="welcome"/>
        </block>
    </reference>
</default>

you got it in a template page :

  • 1column.phtml

  • 2columns-right.phtml

  • 2columns-left.phtml

  • 3columns.phtml

like this : <?php echo $this->getChildHtml('header') ?>

Besides verifies that you have well <?php echo $this->getChildHtml('header') ?> in the templates above. The path : app/design/frontend/{yourpackage}/{yourtheme}/template/page

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.