2012-06-14 51 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

相關問題