Changing the Joomla Contact Form

The Joomla Contact Form

Today I spent several hours hunting around to find a way to preset some of the form fields on the standard Joomla Contact Form.  It's something I would have expected to have been freely available and easily found on the Net.

Why would you want to do that? you may ask:  If I have a series of products in Joomla, each with a link "Contact Me for more Info" at the bottom, unless the customer states which product he is enquiring about, there is no way to know.

So, wouldn't it be nice if you could specify the Subject Line of the email in the link to the Contact Form. As you can see in the image here, the Subject line has been set to REF514 and disabled, so that the customer cannot overwrite it.

Code it Myself

In fact, the code for this is very simple and can easily be inserted into your Joomla template, but you will need ftp access (or a file manager plugin to Joomla) to be able to do this.

Within the com_contact default_form.php I chaged just one line as follows:

<div><input type="text" name="subject"  ="" id="contact_subject" size="30" class="inputbox" <?php="" if(!empty($_get["subject"]))="" echo="" 'value="'.$_GET[" subject"].'"="" disabled'="" ;="" ?="">" /></div>

You can of course tailor this line as you wish.  you could remove the DISABLED option so that the user can add to the subject line, or concatenate it with another message etc...

To install on your system

Download this file -> default_form.php

Within your template directory, create a folder structure as follows:

> html > com_contact > contact

And place this file within the highest level.  Rename it to default_form.php

Make sure that you have a contact setup in ->Components -> Contacts in the Joomla admin backend.

That's it, installed already!

Calling the Contact Form

Now, there are two ways to add a link into your article

1. Manually

In your -> Components -> Contacts make  a note of the ID number (shown at the extreeme right hand side of the list) for both the Contact and the Category that the Contact belongs to.

use the link: /index.php?option=com_contact&view=contact&catid=CC&id=DD&subject=XX

where CC = category ID, DD = Contact ID, XX=subject of email

2. Much more easily, use a system like Linkr or an editor like JCE which have an adnvanced Link Form.  Select the contact who will receive the email and at the end of the link add:



All Done and this should work just great!

Did you know you can hire me?

I take on projects of all sizes. From Consulting to large Development Projects.

If you're starting a new Yii project and would like some help to get setup and running or you need some help with a particular module or you just need someone to develop the whole dang thing, then just ask ...

Leave a Comment