簡體   English   中英

如何在magento的xml文件中添加phtml文件?

[英]how to add an phtml file in xml file of magento?

我是magento的新手,現在要學習,我想在類別列表頁面中添加一些內容,

1,我添加一個名為add.phtml的文件,在其中鍵入<h1>example test</h1> 。(base \\ default \\ template \\ catalog \\ product \\ add.phtml)

2,在\\base\\default\\layout\\catalog.xml我添加了以下內容

  <action method="addPagerLimit" translate="label"><mode>list</mode><limit>all</limit><label>All</label></action>
                        -->
                    </block>
                    <block type="catalog/product_blog" name="add" template="catalog/product/add.phtml"/>

<!--
Category default layout
-->

部分。

為什么在類別頁面上沒有顯示示例test。謝謝

type屬性指示應使用哪個塊(php類)。 在這種情況下,它將在catalog / block / product / blog.php中搜索。 除非您以正確的方式添加Blog.php,否則它將在該部分中斷,因為這不是默認的magento。

您好,我認為您可以在自定義布局xml中創建自定義模塊並覆蓋布局xml,此提示可能會對您有所幫助

使用下面的代碼在類別列表頁面中添加您的phtml文件。

復制此內容,將其粘貼到catelog / layer / left.phpml文件或您想要的任何文件中。

getLayout()-> createBlock('core / template')-> setTemplate('catalog / product / add.phtml')-> toHtml(); ?>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM