Hardcoding A Thank You Page in Joomla

Hardcoding the new Thank You page link directly in the contact.php file doesn't really leave much room for customising things... so I decided to simply add a couple of parameters to the contacts component menu item. This way, the admin can specify whether there should be a Thank You page and if so, the link to it. This solution will preserve the default functionality and add the Thank You page redirect via configuration.

This is what you need to do (hack performed and tested with a 1.0.11 Joomla installation):

1. Edit /administrator/components/com_contact/contact.xml and add the following lines to the end of the <params></params> section, after the session parameter
Code:
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="thankYouPage" type="radio" default="0" label="Thank You Page" description="Separate Thank You Page">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="thankYouURL" type="text" default="" label="Thank You Page URL" size="40" description="The Thank You page to display" />

2. Edit /components/com_contact/contact.php and find the line that says:
Code:
$link = sefRelToAbs( 'index.php?option=com_contact&task=view&contact_id='. $contact[0]->id .'&Itemid='. $Itemid );
3. Insert immediately after that line the following code:
Code:
// content thank you page redirect hack - begin code -
$thankMessage = _THANK_MESSAGE;
$thankyou = $mparams->get( 'thankYouPage', 0 );
if ( $thankyou ) {
$thankyouURL = $mparams->get( 'thankYouURL', '' );
if ( $thankyouURL ) {
// if something has been entered in the URL field we use that otherwise use the link set up above
$link = sefRelToAbs ( $thankyouURL );
$thankMessage = '';
}
}
// content thank you page redirect hack - end code -

4. Replace the line:
Code:
mosRedirect( $link, _THANK_MESSAGE );
with:
Code:
mosRedirect( $link, $thankMessage );
5. Create your Thank You page as a static content item as per first post and find out the link

6. Go to the Contact Us menu item in your menu and you should see the extra parameters at the bottom of the parameter list. Check the Yes radio button for the Thank You Page and enter the thank you page link in the box. Save the changes and you should be all set. The code will automatically convert the link you pasted into SEF so no need to adapt it.

Pasted from <http://forum.joomla.org/index.php/topic,35582.0.html>

Post a Comment

The 411 On S.T.A.N.


Stan Bush's (Me) passions are marketing, music, research, reading, writing and listening. I provide various consulting services, as well as hands on implementation for proof of concept. I began writing Surfin With Stan in 1994 and was published in various Knight-Ridder newspapers. I am self employed. Sales Training And Networking on Google+