Joomla! Discussion Forums



It is currently Thu Nov 26, 2009 7:25 am (All times are UTC )

 


Forum rules

Please submit all new Tips and Tricks to: http://docs.joomla.org/Category:Tips_and_tricks



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ] 
Author Message
Posted: Sat Feb 04, 2006 5:05 pm 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Mon Aug 29, 2005 10:17 am
Posts: 7149
Location: Netherlands/S'pore/Bali/North America
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:
Quote:
$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:
Quote:
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
Quote:
'      '
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

_________________
For Specialized & Individual Support:: http://gws-desk.com
Professional Joomla Web-Development:: http://gws-studio.com
Joomla Specialized Shared & Reseller Hosting at gws-host.com


Last edited by mcsmom on Mon Oct 01, 2007 4:16 pm, edited 1 time in total.

Top
   
 
Posted: Tue Apr 25, 2006 6:07 pm 
User avatar
Joomla! Enthusiast
Joomla! Enthusiast
Offline

Joined: Mon Mar 13, 2006 1:36 pm
Posts: 122
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... :-[

_________________
purpleplanet - Software Solutions :: Custom Joomla Development at http://www.purpleplanet.com :: Free Quotes, Excellent Fresh Designs :: 10% Discount When You Quote "JoomForum09"


Last edited by FluidDruid23 on Tue Apr 25, 2006 6:19 pm, edited 1 time in total.

Top
  E-mail  
 
Posted: Fri May 12, 2006 11:18 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed Nov 16, 2005 10:16 am
Posts: 40
Location: Essex, UK
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 …


Top
  E-mail  
 
Posted: Wed Sep 13, 2006 12:41 am 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Thu Feb 09, 2006 1:41 am
Posts: 811
Location: Auckland, NZ
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:
<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.

Enjoy


Last edited by phlux0r on Wed Sep 13, 2006 12:46 am, edited 1 time in total.

Top
  E-mail  
 
Posted: Fri Sep 15, 2006 3:24 am 
User avatar
Joomla! Champion
Joomla! Champion
Offline

Joined: Mon Aug 29, 2005 10:17 am
Posts: 7149
Location: Netherlands/S'pore/Bali/North America
COOL! and thanks.....(should have been an option in "core" anyhow! imho)

cheers
Leo

_________________
For Specialized & Individual Support:: http://gws-desk.com
Professional Joomla Web-Development:: http://gws-studio.com
Joomla Specialized Shared & Reseller Hosting at gws-host.com


Top
   
 
Posted: Wed Sep 20, 2006 12:01 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Feb 27, 2006 8:22 pm
Posts: 9
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??


Top
  E-mail  
 
Posted: Wed Sep 20, 2006 12:36 pm 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Thu Feb 09, 2006 1:41 am
Posts: 811
Location: Auckland, NZ
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.


Top
  E-mail  
 
Posted: Thu Sep 21, 2006 7:56 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Feb 27, 2006 8:22 pm
Posts: 9
Yes, I did. :-) (forgot to mention that)

Any other ideas?


Top
  E-mail  
 
Posted: Thu Sep 21, 2006 9:00 am 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Thu Feb 09, 2006 1:41 am
Posts: 811
Location: Auckland, NZ
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 :).


Top
  E-mail  
 
Posted: Thu Sep 21, 2006 12:59 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Feb 27, 2006 8:22 pm
Posts: 9
Thanks for your fast replies!  :)

This piece of code was copied directly from the file contact.php that is on my server:

Code:
............. $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.


Top
  E-mail  
 
Posted: Thu Sep 21, 2006 1:22 pm 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Feb 27, 2006 8:22 pm
Posts: 9
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


Top
  E-mail  
 
Posted: Thu Mar 08, 2007 11:20 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Thu May 18, 2006 12:33 pm
Posts: 33
Location: Pittsfield, Maine
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


Top
   
 
Posted: Wed May 09, 2007 2:54 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Tue Apr 17, 2007 4:10 am
Posts: 25
These are great directions! It worked for me and I am a novice at this!! Thanks for the great documentation!!


Top
   
 
Posted: Tue Sep 25, 2007 8:00 am 
User avatar
Joomla! Guru
Joomla! Guru
Offline

Joined: Wed Jan 18, 2006 4:40 am
Posts: 685
many thanks for this great work

_________________
Snadowitz
Current Projects:-
http://www.thunderbirdink.com/
http://www.starcrossedtattoo.com


Top
   
 
Posted: Thu Oct 04, 2007 4:55 am 
Joomla! Fledgling
Joomla! Fledgling
Offline

Joined: Thu Oct 04, 2007 4:34 am
Posts: 2
great ideas !

_________________
Signature Rules: http://forum.joomla.org/index.php/topic,65.0.html


Top
   
 
Posted: Mon Oct 08, 2007 9:53 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Mon Oct 08, 2007 6:46 am
Posts: 20
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


Top
  E-mail  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 16 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group