Page 1 of 1
Guide:: How to REDIRECT after Submit Contact-form!
Posted: Sat Feb 04, 2006 5:05 pm
by leolam
Many questions have been asked on how to
redirect to a Thank-You page after submitting a
contact-us form from the contact component. The current implementation of the Thank you message above the submitted form is a jerk and not very profesional. Here is how to solve this, compliments of JooMaDesk!
- Make a Thank-You page in Static Content. Choose whatever content or title you want to use.
- Create a menu-item (Static-Content) and point it to your Thank-You page or whatever title you have given it. The reason for this is that we want to findout the exact URL of the link to your static content "thank-you" page
- Imagine that your link has got the id's something like http://www.yoursite.com/index.php?optio ... &Itemid=44. This means we now know what the URL is so we can modify some little piece of code...It is only very little!
- Open with a good editor such as Dreamweaver or equivalent the contact.php file, located in components/com_contact
now find on or around line 450 - 452 (in v1.0.10) this code:
$link = sefRelToAbs( 'index.php?option=com_contact&task=view&contact_id='. $contact[0]->id .'&Itemid='. $Itemid );
mosRedirect( $link, _THANK_MESSAGE );
replace that code with the URL for the contact Thank-you page as defined as follows:
mosRedirect( 'http://www.yoursite.com/index.php?option=com_content&task=view&id=15&Itemid=44' )
Indeed you see it correct...the first line has been deleted and if you look sharp (you have to!) you also see
' '
at the beginning and the end. Do not forget those!
If you have SEF enabled and have some nice URL's defined or have something like (example)
http://www.yoursite.com/content/view/15/44/ than put that SEF-based URL into the code...
That's all folks.......This works like a charm on our site......Send us a mail and see for yourself!
Luck
Leo
edited: updated to version 1.0.10 code in contact.php
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Tue Apr 25, 2006 6:07 pm
by FluidDruid23
Hi!
I found this topic, as I need to put a nice redirect in when users send a comment.
Problem is, I can't find this code in contact.php. I am using Joomla 1.08.
Matt
FluidDruid23
EDIT: Found it, sorry. Was being a jerk...
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Fri May 12, 2006 11:18 am
by SteveWR
Great that works but what about the [back] option at the foot of the new Thank You static page.
Just an extra tweak remember to go into the new static thank you page, go to parameters, and Hide the back button, otherwise when someone clicks they go back to the form they have just completed and sent.
Maybe the code on contact.php can be changed so that [back] goes to home page, but that is extra work ...
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Wed Sep 13, 2006 12:41 am
by phlux0r
This post inspired me to extend the hack to be more user friendly.
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
section, after the session parameter
Code: Select all
<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: Select all
$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: Select all
// 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: Select all
mosRedirect( $link, _THANK_MESSAGE );
with:
Code: Select all
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.
Enjoy
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Fri Sep 15, 2006 3:24 am
by leolam
COOL! and thanks.....(should have been an option in "core" anyhow! imho)
cheers
Leo
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Wed Sep 20, 2006 12:01 pm
by Rwin
Have tried this solution but no go.
I get the 'default' message from the langfile.
I altered the files as described, made a static page, made the menu item to fetch the link and pasted the link into 'Thank You Page URL' field.
What am I doing wrong?? Does it have anything to do with having multiple ways/links to the contact information and its forms??
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Wed Sep 20, 2006 12:36 pm
by phlux0r
Did you tick the "Yes" radio button for the Thank You Page when you pasted the URL in the field below? Of course you have to save your edits.
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Thu Sep 21, 2006 7:56 am
by Rwin
Yes, I did. :-) (forgot to mention that)
Any other ideas?
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Thu Sep 21, 2006 9:00 am
by phlux0r
Are you certain that your edits of the file: /components/com_contact/contact.php are in fact in place on the server you are trying this on? Just double check that the code is in the actual file on the server. If that is OK, then all I can suggest is to retrace every step carefully and check if everything is the way that it's described since it works fine for me
.
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Thu Sep 21, 2006 12:59 pm
by Rwin
Thanks for your fast replies! :)
This piece of code was copied directly from the file contact.php that is on my server:
Code: Select all
............. $success = mosMail( $mosConfig_mailfrom, $mosConfig_fromname, $email, $copy_subject, $copy_text );
if (!$success) {
mosErrorAlert( _CONTACT_FORM_NC );
}
}
$link = sefRelToAbs( 'index.php?option=com_contact&task=view&contact_id='. $contact[0]->id .'&Itemid='. $Itemid );
// 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 -
mosRedirect( $link, $thankMessage );
}
}
function vCard( $id ) {
global $database; ..............
I thought I did that correct.
Since I can tick the Yes or No radiobutton and was able to put an url into the "Thank You Page URL" field I figured that the xml file is correct to.
Re: Guide:: How to REDIRECT after Submit Contact-form! [SOLVED]
Posted: Thu Sep 21, 2006 1:22 pm
by Rwin
Ahum,
I had this different approache to my contacts.
I made a "Table - Contact Category" menu-item which displays a table of all contacts.
I also placed it in the topmenu, which isn't the problem since I just checked that.
Why
I made a different menu item linking to "Table - Contact Category" I don't know.
Just now, I found out that all these parameters are in the contact component.
Works like a charme now!!! Thanks for your time and lovely hack ofcourse.
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Thu Mar 08, 2007 11:20 pm
by rberthelette
This is what I'm talking about! Quality posts! Works like a champ! It would be nice to have this redirect built-in as a redirect URL in the Contacts module.
Cheers,
Ray
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Wed May 09, 2007 2:54 am
by curvesahead
These are great directions! It worked for me and I am a novice at this!! Thanks for the great documentation!!
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Tue Sep 25, 2007 8:00 am
by snadowitz
many thanks for this great work
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Thu Oct 04, 2007 4:55 am
by harooon
great ideas !
Re: Guide:: How to REDIRECT after Submit Contact-form!
Posted: Mon Oct 08, 2007 9:53 am
by birkenstam
Thx for that.
is it possible to make this to work in ' Link - Static Content ' ? as it now works with ' Component - Contacts '
if it works with ' Link - Static Content ' then is possible to make other thank you pages with other forms.
i hope you understand my question.
Warm regards Birken