Joomla 1.5 Guide :: How to Redirect Submit Contact form

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
Sulu
Joomla! Apprentice
Joomla! Apprentice
Posts: 18
Joined: Sat Jul 05, 2008 6:40 pm

Joomla 1.5 Guide :: How to Redirect Submit Contact form

Post by Sulu » Sat Jul 05, 2008 9:45 pm

I thought I would share this information because after searching for it myself I could not find one all inclusive guide to redirecting the default submit contact form in Joomla 1.5. In the previous 1.0.xx versions there is a good walkthrough here.

If you were wondering how to get the default contact form in Joomla 1.5 to redirect you to another page after you submit it, or if you wanted to change the default text that is displayed "Thank you for your e-mail" to something else I will explain how in this guide. I cannot be 100% sure this guide will work for people who have certain extensions installed or who have SEO turned on as i have not tried it.

Step One:

First if you don't already have a page that you want to redirect to, you will create one within the Joomla 1.5 admin interface and make sure it is published. I have tried the method below with both an article and a contact page, but it should work for most other page redirects as well.

Step Two:

Next if you don't already know the URL of the page you want to redirect to, you will create a menu item in the Joomla 1.5 admin interface that points specifically to the redirect page you created in step one and make sure it is published. Now when you visit your page in the frontend you will see the menu item for the page you created. Click on that link to view your page. We are doing this because you need to find out the exact URL of the page you created. Make sure to copy the URL as we will need some of it in step 3. After you copy the URL you may un-publish your menu item that links to the redirect page in the admin interface, but make sure you leave the redirect page published.

Step Three:

To finish and make it all work requires editing of a single file in the Joomla installation. If you update or reinstall Joomla you will possibly lose this modification and have to apply it again.

The file that you will be editing is /components/com_contact/controller.php

You can open it in Dreamweaver or other good editors.

(Joomla 1.5.2)
Near lines 193-195 locate:

Code: Select all

$msg = JText::_( 'Thank you for your e-mail');
$link = JRoute::_('index.php?option=com_contact&view=contact&id='.$contact->slug.'&catid='.$contact->catslug, false);
$this->setRedirect($link, $msg);
If you only want to change the text displayed when the contact form is submitted you edit the "Thank you for your e-mail" text below making sure to keep the single quote marks ' before and after.

Code: Select all

$msg = JText::_( 'Thank you for your emaill');
Example:

Code: Select all

$msg = JText::_( 'Thank you for emailing us we will get back to you shortly');
If you want to change the entire page to redirect to the page you created and you don't want the additional "Thank you for your email" text to appear then you should replace this:

Code: Select all

$msg = JText::_( 'Thank you for your e-mail');
$link = JRoute::_('index.php?option=com_contact&view=contact&id='.$contact->slug.'&catid='.$contact->catslug, false);
$this->setRedirect($link, $msg);
with this:

Code: Select all

$link = JRoute::_('paste the URL you copied in Step Two here and keep the single quotes before and after');
$this->setRedirect($link);
Make sure you paste the URL from step two starting with the first index.php you see until the end so that your final code looks similar to this example:

Code: Select all

$link = JRoute::_('index.php?option=com_content&view=article&id=53&Itemid=64');
$this->setRedirect($link);
I think that you can place an entire URL starting with http:// using the same method but I have not tried it and can not say for sure.

I hope this helps some of you who were searching for this information like I was. Please feel free to follow up with confirmations on if this works with SEO or if you can use a full URL including http:// .

User avatar
gene_x
Joomla! Apprentice
Joomla! Apprentice
Posts: 15
Joined: Tue May 23, 2006 3:27 pm
Contact:

Re: Joomla 1.5 Guide :: How to Redirect Submit Contact form

Post by gene_x » Tue Jul 08, 2008 7:09 pm

Thanks!

I'm using joomla core SEO includind the .htaccess to remove the index.php.
This hack work for me.
In this part:

Code: Select all

$link = JRoute::_('put the alias of the page here, without the index.php');
In my case:

Code: Select all

$link = JRoute::_('thankyou-page');


Locked

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”