简体   繁体   中英

how to add an phtml file in xml file of magento?

i am a new learner of magento, now, to learn, i want to add some content in the category list page,

1,i add a file named add.phtml, in which i typed <h1>example test</h1> .(base\\default\\template\\catalog\\product\\add.phtml)

2,in \\base\\default\\layout\\catalog.xml i added the following

  <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"/>

under

<!--
Category default layout
-->

part.

why on the category page, there is no show example test.thank you

The type attribute indicates which Block (php class) it should use. In you case it will search in catalog/block/product/blog.php. Unless you added a Blog.php the right way, it will break on that part as this is not default magento.

您好,我认为您可以在自定义布局xml中创建自定义模块并覆盖布局xml,此提示可能会对您有所帮助

Use bellow code to add your phtml file in category list page.

copt this paste it in to catelog/layer/left.phpml file Or any file where you want.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM