In the Mage/Contacts/controllers/IndexController.php file, you will find the postAction (which is called by your /contacts/index/post url). In it, you will find in several places the call to the method “_redirect(’*/*/’);” This is the method that redirects you at the end of the Post process towards /contacts/index. You could change it to “_redirect(’/kontacta-oss/index’)” if you want to.
But I prefer to tell you it’s better not to change the core/Mage code… Then, you’ll have to do what I wrote above, but in a controller-overriding manner. You have several topics explaining how to do that.
In the Mage/Contacts/controllers/IndexController.php file, you will find the postAction (which is called by your /contacts/index/post url). In it, you will find in several places the call to the method “_redirect(’*/*/’);” This is the method that redirects you at the end of the Post process towards /contacts/index. You could change it to “_redirect(’/kontacta-oss/index’)” if you want to.
But I prefer to tell you it’s better not to change the core/Mage code… Then, you’ll have to do what I wrote above, but in a controller-overriding manner. You have several topics explaining how to do that.
2. I change the “core mage” file and can send mail but the statsus message doesn’t work.
3. I try to make a static block instead with the contact text and put the block into the form.phtml or in the contact.xml. This work too but the page have no breadcrumbs.
I’d like to answer all of your questions, but that would not be right. I mean we need to capitalize answers so that everybody can see these forum topics and learn from them.
So, if your first problem has been solved, please put [SOLVED] in front of its title. As for the other questions, make other topics in the right categories.
If you really want to include the contact form on a CMS page, you can try my solution. It could be improved, but it works. If you only need to add some content to the default contact form, you should use InitechDesign’s solution (http://www.magentocommerce.com/boards/viewthread/33118/P15/)
Adding the contact form to a CMS page:
1:
Include the form (in the cms page) by using this code:
3:
Modify the controller’s redirects: app/code/core/mage/contacts/controllers/IndexController.php
Lines108, 115 and 120 contain the locations your visitors will be redirected to after submitting their message. Replace them with your cms page location.
4:
Make confirmation message show up:
Go to /app/design/frontend/default/yourstore/template/contacts/form.phtml and replace line 28:
You could also try this. We use it in a category. That cat is now our contact form. ( -> Catalog -> Manage category -> Description ) Change the Display mode in “static block only” And name the category “Contact form”, or what ever name you want.
Great advice! I found your step-by-step answer very approachable. I am still fiddling with getting the confirmation message to show, but otherwise, thanks to you, my contact form is running smoothly!
Please be very careful changing the core php files, it means that you will break your installation when you upgrade. always take a copy of the file and place it in the /app/code/local folder with the same subfolder path.
This last step is not working for me. Everything else is working but I’m not seeing any status messages (on the page to which I’m redirecting). In my case, this is a product view page. Would that make any difference? Is the session emptied for some reason upon redirect?
All I’m getting is the string “messages”. I’m using the following (in my controller postAction method) to do the redirect:
My issue seemed to be that I was creating session files in 2 locations - one in the default location (from php.ini) and once in the session folder (/var/session) and the contents of these files differed. Upon redirect (for me that was back to the Product view page), I was picking up the wrong session (wrong session file) which didn’t have my status messages in it - they were in the other session file (which confusingly even had the same ID).
In the Mage/Contacts/controllers/IndexController.php file, you will find the postAction (which is called by your /contacts/index/post url). In it, you will find in several places the call to the method “_redirect(’*/*/’);” This is the method that redirects you at the end of the Post process towards /contacts/index. You could change it to “_redirect(’/kontacta-oss/index’)” if you want to.
But I prefer to tell you it’s better not to change the core/Mage code… Then, you’ll have to do what I wrote above, but in a controller-overriding manner. You have several topics explaining how to do that.
Hi, I am having this redirect problem, perhaps you or someone here can help me.
I have included my contact form in two different cms pages. I’d like the redirect to the page it was on! Say if it was on the Customer Service cms page then it should stay there and simply show a “submitted confirmation message”. And if it was on the Contact us page, then it should stay there and simply show message. How do i make it possible.
My form doesn’t even respond at all when i hit submit.
I think this is nearly the straw that broke the camel’s back.
I was pretty much set to go live today and was finalising my list of tweaks and corrections and I came across the contact form not working issue which I’d left to the end as I, wrongly, assumed it would be a simple thing to work out.
How in the name of all that’s holy could a contact form be so complicated. I’ve got a ridiculous number of tabs open and am still no closer. My form works if I change my form action to:
but when I submit the form I get taken to that URL and only get redirected to /contacts/index instead of the CMS page on which I had added the contact form in the first place - so none of the other content of that page appears. I definitely do not want to go messing with core hacking, I learnt to avoid that a long time ago. I tried just making my topLinks “Contact Us” link to /contacts/index/ but of course none of my non-form page content shows up. I worked out that I could just manually hand-code the content into /contacts/form.phtml but that seems to defeat the point of a CMS and my client will wonder. I know I could include a static block at the top of that page but noticed that my breadcumbs functionality is cocked when using /contacts/index/, again I could just manually hand code the breadcrumbs in. I’ve even considered just dumping the form.phtml behaviour, bypassing Magento’s email system and just writing my own PHP script that actions to self and if isset a hidden POST field saying the form has been submitted then mail() the results.
But seriously, what the hell has made this simple contact form so complicated. This has most definitely nearly cracked me after a few weeks of intense confusion. Every time I think I have a handle on what’s going on something comes up that evaporates 6 hours of my time.
So I’ve hacked it into a just about acceptable thing. User submits form. Between contacts.xml and form.phtml which is called due to lack of proper redirection I have set another static block to be called, in which I’ve duplicated the content of the pre-form CMS page content. I had already tried to work out calling the CMS page content directly in form.phtml but gave up after 20 minutes of searching in circles.
So anyway, user submits form and are brought to a page where breadcrumbs disappear as they weren’t working anyway, and my client has to be informed that if they want to change their contact us intro text, they have to change it in the CMS page and a static block.