I have a custom contact-us form that is a CMS pages.
After submitting the contact form I want to redirect back to the CMS page with the custom contact form.

I need to edit the controller (app/code/core/Mage/Contacts/controllers/IndexController.php) and change the $this->_redirect('*/*/'); lines.

And I also found out that I need to edit the contact form .phtml file (app/design/frontend/theme/theme/contacts/form.phtml) with:

<div id="messages_product_view">
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>


<?php Mage::app()->getLayout()->getMessagesBlock()->setMessages(Mage::getSingleton('customer/session')->getMessages(true)); ?>

But I do not want to edit the core file. So I want to override the default contact controller.
Therefore I found this URL.

But I do not know where I need to create the config.xml and what code I what code I need inside my custom IndexController.php file to achieve what I want.

What do I exactly need to do, to achieve this?

  • why you does not rewrite IndexController?
    – Amit Bera
    Sep 14, 2015 at 10:18
  • @AmitBera Where and how do you mean to rewrite IndexController?
    – JGeer
    Sep 14, 2015 at 10:21
  • How you have call this contact us on cms?As a idea use magento.stackexchange.com/questions/70475/…
    – Amit Bera
    Sep 14, 2015 at 10:52
  • @AmitBera Thanks for the URL. But where do I need to place the config.xml file? I use this to call the contact form: <reference name="content"> <block type="core/template" name="contactForm" template="contacts/offerte.phtml"> <action method="setFormAction"><value>/contacts/index/post</value></action> <block type="studioforty9_recaptcha/explicit" name="studioforty9.recaptcha.explicit" template="studioforty9/recaptcha/explicit.phtml"> <action method="setAllow"><value>true</value></action> </block> </block> </reference>
    – JGeer
    Sep 14, 2015 at 11:34


Your Answer

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

Browse other questions tagged or ask your own question.