开发者

How to render a block in magento .phtml file?

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?


As long as the XML block is placed correctly, in a phtml file you should be able to bring it out with:

<?php echo $this->getChildHtml('contactForm') ?>


If you want to have the contact form with in a phtml page then...

  1. 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:

    <block type="core/template" 
           name="contactForm" 
           form_action="/contacts/index/post" 
           template="contacts/form.phtml"/>
    
  2. just add the getChildHtml:

    getChildHtml('contactForm') ?>

So simple, I know, but took me 3 coffees like all easy things in magento...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜