I want to create the custom header in Magento 1.9. I attached the screenshot of the header like this

enter image description here

I have tried the following code. I have created the static block and static block calling in the header.phtml file

     <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('custom_block_id')->toHtml() ?>

but this code is not working .please suggest me

I have added this original header not working. Menu and logo not displaying.

     <!--- custom header---->    
  <reference name="header">
      <block type="page/header" name="header">
         <action method="setTemplate"><template>page/html/customheader.phtml</template></action> 
        <!--- original header---->
         <reference name="header">
        <!-- Search box wrapper -->
        <block type="page/html_header" name="search_wrapper" template="page/html/search_wrapper.phtml">
            <action method="insert">

  • Did you get any solution ? – Pawan Aug 7 '18 at 3:34
  1. Add the code bellow in : app/design/frontend/{yourpackage}/{yourtheme}/layout/local.xml

    <reference name="header">
        <block type="{block}/{type}" name="custom.header" template="page/html/custom-header.phtml" before="-"/>
  2. Create your custom header in : app/design/frontend/{yourpackage}/{yourtheme}/template/page/html/custom-header.phtml

  3. Add <?php echo $this->getChildHtml('custom.header'); ?> in app/design/frontend/{yourpackage}/{yourtheme}/template/page/html/header.phtml

    Info : in <block type="{block}/{type}" if you haven't a custom block for your phtml, please put : <block type="core/template" ...

    before="-" to place it at the top of the header container.


For a Static block:

in local.xml

<reference name="header">
    <block type="cms/block" name="custom.header">
        <action method="setBlockId"><block_id>block-id-here</block_id></action>

Then : app/design/frontend/{yourpackage}/{yourtheme}/template/page/html/header.phtml

Add this : <?php echo $this->getChildHtml('custom.header'); ?>

| improve this answer | |
  • @pirnce i have created static block then how can write ? – pramod24 Aug 7 '18 at 12:59
  • Please Look my update – PЯINCƏ Aug 7 '18 at 13:05
  • Hi prince i have updated local.xml and custom-header.phtml in above theme folder but it's not working – pramod24 Aug 7 '18 at 13:24
  • Clean the cache, and check well the id of your custom block <block_id>block-id-here</block_id> block-id-here you replace it by the id of your static block – PЯINCƏ Aug 7 '18 at 13:32
  • first i have created custom-header.phtml and In that phtml file added div content and that phtml file called in local.xml file using <block type="core/template" – pramod24 Aug 7 '18 at 13:37

Try to add this code in your xml :

<reference name="header">
    <block type="core/template" name="customheader" template="customheader.phtml"/>

And write your custom code in customheader.phtml file.

It may be helpful for you.

| improve this answer | |
  • i have added custom header but original header content not working. my menu and logo not display. – pramod24 Aug 7 '18 at 6:01

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.