How to make a block in magento.phtml file?

I am trying to display a magento contact form in a .phtml file, but I cannot find anything on Google to get the PHP code for this.

I only know the code to use in the magento CMS system, which:

{{block type="core/template" name="contactForm" form_action="/contacts/index/post" template="contacts/form.phtml"}} 

Any clues?

+4
source share
2 answers

As long as the XML block is placed correctly, in the phtml file you can output it with:

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

If you want to have a contact form on the phtml page, then ...

  • add the block to xml that you want, for example, I wanted to add a request form to the product view, so I went to the .xml directory in <reference name="content"> and added:

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

    getChildHtml ('contactForm')? >

It’s so simple, I know, but I took 3 coffee, like all light things in purple ...

+3
source

All Articles