I have a customlayout which looks like this:

<custom_structure_index translate="label">
    <reference name="root">
        <action method="setTemplate"><template>page/1column.phtml</template></action>
    <reference name="content">
        <block type="custom/ueblock" template="unreal/custom/formsubmit/formsubmit.phtml" ></block>

This is refering to standard 1column.phtml

<?php echo $this->getChildHtml('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') ?>
        <?php echo $this->getChildHtml('footer_before') ?>
        <?php echo $this->getChildHtml('footer') ?>
        <?php echo $this->getChildHtml('global_cookie_notice') ?>
        <?php echo $this->getChildHtml('before_body_end') ?>
<?php echo $this->getAbsoluteFooter() ?>

This works like a charm. But I know I don't want to change the content but the header. So I thought adding a reference with header as a name would do the trick

<reference name="header">
    <block type="custom/ueblock" template="unreal/custom/header.phtml" ></block>

Unfortunately I was wrong. Is it possible to update specific content blocks by using the reference tag in my custom.xml or what would be the approach to solve this with a minimum amount of effort?

**** EDIT ****

When I add the following it works but not for header and I dont understand why

        <reference name="footer">
            <block type="custom/ueblock" name="footer" template="unreal/custom/footer.phtml" before="-"></block>
  • what you want to update? – MeenakshiSundaram R Nov 18 '15 at 13:19
  • e.g I want to update the header and use my own header version – xhallix Nov 18 '15 at 13:20
  • Are you trying to add a custom block to the header or change the template of the header? – Yiorgos Moschovitis Nov 18 '15 at 15:34
  • I just want to extend the header by using layout <reference> with my own header. This works for everyname expect header (e.g name="footer" works fine) – xhallix Nov 18 '15 at 15:53

Create the new header.phtml file in $YOURPACKAGE/$YOURTHEME/page/html/header.phtml and ensure you set the default theme to yours in the backend.

Magento will give priority to your file avoiding the template fallback with no need to rewrite the block.


Header template is defined in constructor of class Mage_Page_Block_Html_Header
You need to override this class and the constructor of this to have different header template.

  • sorry,I just want to use my own template as a header, like I did for content but not overriding the block in anyway – xhallix Nov 18 '15 at 13:33

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.