2014-06-10 51 views
0

我是Magento的新手。我正在研究如何创建1个模块。我想将Mangento的标题默认添加到我的页面。如何在Magento的另一个页面中添加标题

这是/frontend/base/default/template/demo/necrolyte/product_page.html文件

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

这是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> 

这个结果上浏览器屏幕是“你好”,它不会出现我想要的Magento头默认。

回答

1

您好检查下面的代码

<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> 
+0

这对我很有帮助。 – user3541964

0

她不需要在layout中添加页眉添加。自动添加页眉和页脚,只需在demo/necrolyte/product_page.phtml中检查this->getChildHtml('header') is exiting即可。

根据你的代码product_page.phtml is template layout file for your此页类似的Magento列,2列,left.phtml等

<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> 
1

在Magento,把整个页面为块,以root作为最顶端的一个定义在page.xml中,然后调用它内部的子块,可以使用引用标签修改它。

你只需要使用,

<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> 
+0

这对我来说是有帮助的 – user3541964

相关问题