[英]How to render a block in magento .phtml file?
我试图将magento联系表单呈现为.phtml文件,但我在Google上找不到任何可以获取PHP代码的内容。
我只知道在magento的CMS系统中使用的代码是:
{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}
有线索吗?
只要XML块正确放置,在phtml文件中你就应该能够将它带出来:
<?php echo $this->getChildHtml('contactForm') ?>
如果你想在一个phtml
页面中有联系表格,那么......
将块添加到您想要的xml中,例如我想将一个请求表单添加到产品视图中,因此,我转到<reference name="content">
catalog.xml并添加:
<block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"/>
只需添加getChildHtml
:
我知道,这么简单,但是我带了3个咖啡,比如magento中的所有简单的东西......
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.