0

I am not much familiar with many feature of magento but I know that to display form, we can use the following in pages.

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

but I have a requirement that needs me to put it under categories, how can I use the same code under "custom layout update" or code it in my template.

10
  • check my updated answer Sep 19, 2016 at 17:29
  • Have you checked my updated answer Sep 21, 2016 at 7:53
  • @MurtuzaZabuawala where should i use that code?
    – localhost
    Sep 21, 2016 at 8:31
  • in your /app/design/frontend/my_mod/default/layout/layout.xml Sep 21, 2016 at 8:36
  • @MurtuzaZabuawala great, now when i submit my form, it says 404. Do i need to setup something in order to use form?
    – localhost
    Sep 21, 2016 at 10:23

1 Answer 1

0

for display in category layout update you can use below code , please try and let me know if its not working.

  <catalog_category_default>
  <reference name="content">
    <block type="core/template" name="contactForm" template="contacts/form.phtml" >
        <action method="setFormAction">
          <form_action>{{baseUrl}}"/contacts/index/post"</form_action>
        </action>
    </block> 
</reference>
</catalog_category_default> 

and also write same code for

  <catalog_category_layered>
  <reference name="content">
    <block type="core/template" name="contactForm" template="contacts/form.phtml" >
        <action method="setFormAction">
          <form_action>{{baseUrl}}"/contacts/index/post"</form_action>
        </action>
    </block> 
</reference>
</catalog_category_layered> 

If you are using in your cms page then

Change your cms page like this

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

and open your contacts/form.phtml file and change your action method like this

  action = '<?php echo Mage::getBaseUrl();?>contacts/index/post ' 
3
  • I didn't work I pasted in under my module /app/design/frontend/my_mod/default/layout/layout.xml
    – localhost
    Sep 19, 2016 at 16:42
  • check my updated answer Sep 19, 2016 at 16:45
  • I have updated my answer Sep 21, 2016 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.