2012-06-14 50 views
1

我有一个模块名称空间/搜索,当我到达此处时安装了该模块。我从它里面取了< [namespace] _index_index>内容并在此处显示。这是来自当前正在工作的模块。模板不适用于自定义前端模块

<reference name="root"> 
    <action method="setTemplate"><template>page/2columns-right.phtml</template></action> 
</reference> 
<reference name="content"> 
    <block type="search/search" name="search" template="ifi_search/index.phtml" /> 
</reference> 

我已经使用上述作为helloworld模块的模板。

<reference name="root"> 
    <action method="setTemplate"><template>page/2columns-right.phtml</template></action> 
</reference> 
<reference name="content"> 
    <block type="helloworld/helloworld" name="helloworld" template="helloworld/helloworld.phtml" /> 
</reference> 

随着我留下了一个完全空白页第二个例子中,开发人员模式已开启。为了扩大我对这个主题的知识,我没有任何其他的信息可以用于调试。如果添加了任何有用的内容,请发表评论。我不确定是否可以在这一点上重现此问题。

+0

根据页面顶部的警告,该文章包含一些令人讨厌的信息,即使信息没有过期。也就是说,根据下面的@benmarks,如果你像这样替换了根块,并且Magento可以做到这一点,你需要一个output =“toHtml”属性。 –

+0

我正在运行一个旧版本的Magento,所以我没有看到文章被告知是问题。我不是复制我的,而是复制了第二个示例中的部分代码并进行了编辑,但我一定在事故中删除了output =“toHtml”,但没有意识到它。我已经尝试了几种不同的变体,以及IndexController中的几种不同的方法。我发现做的工作是使用 page.phtml Sturm

回答

3

您需要添加output属性,在块声明:

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

这标志着块作为输出块,并设置块的渲染方法来toHtml()。输出块在Mage_Core_Controller_Varien_Action->renderLayout()的调用中呈现入口点。

+0

抱歉关于输出=“toHtml”的混淆。我没有从文章中粘贴正确的代码。我会更新问题以反映输出,但它仍然完成同样的事情。 – Sturm

相关问题