This article offers a solution to redirect users to a confirmation page when the contact form of is submitted in Joomla.
One of the standard features used by most Joomla websites is the built-in enquiry form displayed on the contact page. It is a simple email enquiry form that is shipped as part of Joomlas default contact component. Unfortunately however, it is not possible to redirected users to a confirmation page when a user submits an enquiry via the contact form, they are. This is a common usability issue reported by Web designers and developers who use Joomla to design websites. This article discusses a solution to this problem.
Problem: When a user submits an enquiry via the contact form, they are not redirected to a confirmation page. Although a default confirmation text is displayed on top of the contact form, the current configuration does not offer the ability to redirect users to a page of your choice.
Solution: A small hack or code change to Joomlas code can help achieve this. The simple change does not required web design or Joomla experience as the steps outlined in this article are sufficient to redirect users to a page of your choice.
Joomla contact form – How to redirect users
Using the article manager of Joomla, create the page you would like to redirect users to. This can be a simple ‘Thank you for your enquiry’ page or other relevant information. After you have saved the article, make a note of its ‘id’. You need the id of the page in order to provide a redirection URL.
Make a note of the URL or link of the redirect page. If you have created a custom redirect page in article manager, then the redirect link will be ‘index.php?option=com_content&view=article&id=64′. Please replace 64 in the link with the correct id of the confirmation page you have created in article manager. The id will be listed in the last column of the article manager.
Download the contact component file that needs to be updated. You will need FTP access to your website hosting provider in order to update the file. The Joomla file that you need to update is called ‘controller.php’ and is available in com_contact folder within the components folder of Joomla. The full path to the file is as follows:
Finally, in order for the redirection to work, you will need to amend a couple of lines of code in the above Joomla file (controller.php).You can use notepad or your favourite HTML editor such as Dreamweaver or Frontpage to update the file.
Locate the following lines of code. You can use the find feature. On Joomla 1.5.2X it is located on line 193.
Existing Joomla Code:
$ msg = JText::_( ‘Thank you for your e-mail’);
$ link = JRoute::_(‘index.php?option=com_contact&view=contact&id=’.$ contact->slug.’&catid=’.$ contact->catslug, false);
$ this->setRedirect($ link, $ msg);
Replace the above code with the following: This will redirect users to a conformation page when user makes an enquiry via the contact form on your website.
Example of your new Code:
Replace the above existing code with the following code:
$ link = JRoute::_(‘index.php?option=com_content&view=article&id=64′);
$ this->setRedirect($ link);
The author, K.Singh is a Web Design and http://www.kronikmedia.co.uk/joomla-development.jsp> Joomla Development Consultant with London based http://www.kronikmedia.co.uk> Web Design Company. The author has 10 years of consulting experience with businesses in London.