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>

Comments

Popular posts from this blog

Change The Format Of Blogger's Popular Post Widget

Keyboard Failed (and so did you)

Video Not Available In Your Country Fix