HomeMagento® Custom Contact FormsTutorialsAdding Forms to phtml Templates

Adding Forms to phtml Templates

If you’d like to insert a contact form into a phtml template you can use the following code snippet:

<?php
$filter = Mage::getModel('widget/template_filter');
echo $filter->filter('{{widget type="plugincompany_contactforms/form_widget_view" form_id="1"}}');
?>

If you’d like to add a pop-up contact form to a phtml template, the code snippet looks as follows:

<?php
$filter = Mage::getModel('widget/template_filter');
echo $filter->filter('{{widget type="plugincompany_contactforms/form_widget_view" form_id="1" show_widget_as_link="1" display_as_button="1" link_title="Contact Us" link_alignment="none"}}');
?>

In both examples, the bold {{widget code}} can be generated by adding a Custom Contact Forms widget to a CMS page or block.

Was this article helpful to you? Yes 3 No