user3541964
user3541964

Reputation: 107

How to add header in another page in Magento

I am a newbie with Magento. I am studying way to create 1 module. I want add header default of Mangento to my page.

This is file in /frontend/base/default/template/demo/necrolyte/product_page.html

<div class="main-content">
 <h1>Hello</h1>
</div>

This is local.xml

<layout version="0.1.0">
<necrolyte_product_index>
    <reference name="root">
      <block type="page/html_header" name="header" as="header" template="page/html/header.phtml"/>
    </reference>
    <block type="page/html" name="root" output="toHtml" template="demo/necrolyte/product_page.phtml">

    </block>
</necrolyte_product_index>

This result on browser screen is "Hello", it doesn't appear header default of Magento as i would like.

Upvotes: 0

Views: 1240

Answers (3)

Amit Bera
Amit Bera

Reputation: 7611

Her are no need to add header add in layout.it automatically comes to header and footer,Just check this->getChildHtml('header') is exiting in demo/necrolyte/product_page.phtml.

According to your code product_page.phtml is template layout file for your this page like magento columns and, 2-columns-left.phtml etc

<layout version="0.1.0">
<necrolyte_product_index>

    <block type="page/html" name="root" output="toHtml" template="demo/necrolyte/product_page.phtml">

    </block>
</necrolyte_product_index>

Upvotes: 0

Vishal
Vishal

Reputation: 900

Hello check below code

<layout version="0.1.0">
<necrolyte_product_index>
<reference name="content">
    <block type="page/html" name="root" output="toHtml" template="demo/necrolyte/product_page.phtml">
     </block>
</reference>
</necrolyte_product_index>

Upvotes: 1

huzefam
huzefam

Reputation: 1191

In Magento, treat whole page as a block, with root as the top most one ,defined in page.xml, and then child blocks called inside it , which can be modified using reference tag.

you just need to use,

<layout version="0.1.0">
<necrolyte_product_index>
    <reference name="content">
    <block type="page/html" name="myproductpage" template="demo/necrolyte/product_page.phtml" />
</reference>
</necrolyte_product_index>
</layout>

Upvotes: 1

Related Questions