Guide:: How to REDIRECT after Submit Contact-form!

A forum with Tips, tricks and small tutorials.

Moderators: mcsmom, unixboymd

Forum rules
Post Reply
User avatar
leolam
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 155
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/S'pore/Bali/North America
Contact:

Guide:: How to REDIRECT after Submit Contact-form!

Post by leolam » Sat Feb 04, 2006 5:05 pm

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
Last edited by mcsmom on Mon Oct 01, 2007 4:16 pm, edited 1 time in total.
For Professional Web-Development:: http://joomastudio.com
For Specialized Joomla Support:: http://joomadesk.com
We provide dedicated Joomla-Hosting at joomaserver.com!
Skype: joomadesk

User avatar
FluidDruid23
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Mar 13, 2006 1:36 pm
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by FluidDruid23 » Tue Apr 25, 2006 6:07 pm

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... :-[
Last edited by FluidDruid23 on Tue Apr 25, 2006 6:19 pm, edited 1 time in total.
purpleplanet - Software Solutions :: Custom Joomla Development at http://www.purpleplanet.com :: Free Quotes, Excellent Fresh Designs :: 10% Discount When You Quote "JoomForum08"

User avatar
SteveWR
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Nov 16, 2005 10:16 am
Location: Essex, UK
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by SteveWR » Fri May 12, 2006 11:18 am

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 ...
http://www.esprit-internet.co.uk 
OK look i've searched alreadeeeeeeeeeeeee …

User avatar
phlux0r
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Feb 09, 2006 1:41 am
Location: Auckland, NZ
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by phlux0r » Wed Sep 13, 2006 12:41 am

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
Last edited by phlux0r on Wed Sep 13, 2006 12:46 am, edited 1 time in total.

User avatar
leolam
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 155
Joined: Mon Aug 29, 2005 10:17 am
Location: Netherlands/S'pore/Bali/North America
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by leolam » Fri Sep 15, 2006 3:24 am

COOL! and thanks.....(should have been an option in "core" anyhow! imho)

cheers
Leo
For Professional Web-Development:: http://joomastudio.com
For Specialized Joomla Support:: http://joomadesk.com
We provide dedicated Joomla-Hosting at joomaserver.com!
Skype: joomadesk

Rwin
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Feb 27, 2006 8:22 pm

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by Rwin » Wed Sep 20, 2006 12:01 pm

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??

User avatar
phlux0r
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Feb 09, 2006 1:41 am
Location: Auckland, NZ
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by phlux0r » Wed Sep 20, 2006 12:36 pm

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.

Rwin
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Feb 27, 2006 8:22 pm

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by Rwin » Thu Sep 21, 2006 7:56 am

Yes, I did. :-) (forgot to mention that)

Any other ideas?

User avatar
phlux0r
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Thu Feb 09, 2006 1:41 am
Location: Auckland, NZ
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by phlux0r » Thu Sep 21, 2006 9:00 am

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 :).

Rwin
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Feb 27, 2006 8:22 pm

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by Rwin » Thu Sep 21, 2006 12:59 pm

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.

Rwin
Joomla! Fledgling
Joomla! Fledgling
Posts: 4
Joined: Mon Feb 27, 2006 8:22 pm

Re: Guide:: How to REDIRECT after Submit Contact-form! [SOLVED]

Post by Rwin » Thu Sep 21, 2006 1:22 pm

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.  :D

User avatar
rberthelette
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Thu May 18, 2006 12:33 pm
Location: Pittsfield, Maine
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by rberthelette » Thu Mar 08, 2007 11:20 pm

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

curvesahead
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Tue Apr 17, 2007 4:10 am

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by curvesahead » Wed May 09, 2007 2:54 am

These are great directions! It worked for me and I am a novice at this!! Thanks for the great documentation!!

User avatar
snadowitz
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Wed Jan 18, 2006 4:40 am
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by snadowitz » Tue Sep 25, 2007 8:00 am

many thanks for this great work
Snadowitz
My pet projects:-
http://www.starcrossedtattoo.com - great art.....
http://www.thetaxback.co.uk - personal taxation matters!

harooon
Joomla! Fledgling
Joomla! Fledgling
Posts: 2
Joined: Thu Oct 04, 2007 4:34 am
Contact:

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by harooon » Thu Oct 04, 2007 4:55 am

great ideas !

birkenstam
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Mon Oct 08, 2007 6:46 am

Re: Guide:: How to REDIRECT after Submit Contact-form!

Post by birkenstam » Mon Oct 08, 2007 9:53 am

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


Post Reply