如何在 magento .phtml 文件中渲染块?
我正在尝试将 magento 联系表单呈现为 .phtml 文件,但我在 Google 上找不到任何内容来获取 PHP 代码来执行此操作。
我只知道在magento的CMS系统中使用的代码是:
{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}
有任何线索吗?
I am trying to render the magento contact form into a .phtml file, but I cannot find anything on Google to get the PHP code to do it.
I only know the code to use in magento's CMS system which is:
{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}}
Any clues?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只要正确放置 XML 块,您就应该能够在 phtml 文件中将其显示出来:
As long as the XML block is placed correctly, in a phtml file you should be able to bring it out with:
如果您想在
phtml
页面中包含联系表单,那么...将块添加到您想要的 xml 中,例如我想将请求表单添加到产品视图中,所以,我转到
处的catalog.xml并添加:只需添加
getChildHtml
:getChildHtml('contactForm') ?>;
很简单,我知道,但我花了 3 杯咖啡,就像 magento 中所有简单的事情一样......
If you want to have the contact form with in a
phtml
page then...add the block to the xml you want for example I wanted to add a request form to the product view so, i went to catalog.xml at the
<reference name="content">
and add:just add the
getChildHtml
:getChildHtml('contactForm') ?>
So simple, I know, but took me 3 coffees like all easy things in magento...