3

I have three contact-us forms that are CMS pages. They are on separate websites, and they all have different URL keys. The CMS pages have their own phtml forms but use the same controller action (form_action="/contacts/index/post") for posting as defined in the CMS.

Current behavior:

Each of these forms submit just fine, but, after submission, they are redirected to the /contacts/index/ (through $this->_redirect('*/*/')) and the redirected pages are not what the customer started from, of course.

Desired behavior:

I would like the redirected page to be the same form page that the customer starts from. What's one of the cleanest and make-sense way to do this? Should I create an extension with a controller that basically does what the Mage_Contacts module does, but with a different redirect logic?

  • use the method $this->_redirect('*/*/'); in your controller. I think that is the best option. – Rajeev K Tomy Mar 28 '14 at 1:03
  • Try using $this->_redirectReferer() instead of $this->_redirect('*/*/') – Marius Mar 28 '14 at 8:31
  • @Marius, would you do what I said to produce the desired behavior (i.e. create a controller that does basically the same thing as contacts/index/post with the redirect to the referer`) or approach it differently? I'm just trying to get an idea of how people would approach and solve this kind of issues. – musicliftsme Mar 28 '14 at 13:43
  • @laketuna I would override the default contact controller. inchoo.net/ecommerce/magento/…. And in the postAction method I would call the same code except the redirect part. – Marius Mar 28 '14 at 13:48
  • @Marius, OK, that sounds good, and it was what I was thinking would be the best approach. Feel free to create an answer for it! – musicliftsme Mar 28 '14 at 13:55
3

As described in the comments....

I would override the default contact controller and in the postAction method I would call the same code except the redirect part.
Instead of calling at the end

$this->_redirect('*/*/');

I would call

$this->_redirectReferer();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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