Edit Joomla Estate Agency Contact Form

Joomla Estate Agency is an excellent real estate component for joomla. After using it for several sites and spending some time in the support forum I noticed there seemed to be some confusion on how to edit the property contact forms.

So here is how to do it....

For the purpose of this tutorial we're going to hide the subject box while still sending the reference, and add some date enquiry boxes.

Editing the Form

The first file we need to edit is the contact form it's self. This is located in

 /components/com_jea/views/properties/tmpl/default_item.php

The form code starts around line 160 with the line{code}{/code}

<form action="<?php echo $this->getViewUrl ($this->row->id,'&task=sendmail' ) ?>" method="post" enctype="application/x-www-form-urlencoded">

To hide the subject (The subject is the title of the property which the sender already knows so doesn't really need to be seen, just sent) Look for the following line:

<input type="text" name="subject" id="subject" value="Ref : <?php echo $this->escape( $this->row->ref ) ?>" size="40" />

and replace it with the following to change the input type to "hidden"{code}

<input type="hidden" name="subject" id="subject" value="Ref : <?php echo $this->escape( $this->row->ref ) ?>" size="40" />

To add a new field we can basically copy another and give it a unique id. I'm going to add 2 new fields for reservation dates using the id's "from" and "to" using the following lines:

<p><label for="from"><?php echo JText::_('From') ?> :</label> <input type="text" name="from" id="from" value="dd/mm/yyyy" <?php echo JRequest::getVar('from', '') ?> size="10" maxlength="10"> </p>

<p><label for="to"><?php echo JText::_('To') ?> :</label> <input type="text" name="to" id="to" value="dd/mm/yyyy" <?php echo JRequest::getVar('to', '') ?> size="10" maxlength="10"> </p>

If you want the label to be translateable you need to include the php echo JText part. Then in the language files for the component (/language/en-GB/en-GB.com_jea.ini or fr-FR/fr-FR.com_jea.ini) you add the translation for each language like this

FROM=text I want to display for this language for the word from

Now that we have the new fields in the form we need to put the new information into the email.

Edit the Email Information

The file responsible for sending the email is:

/components/com_jea/controllers/properties.php

The sendmail function starts around line 165 with the line:

function sendmail()

We first need to add our variables from the form, so scroll down to

JRequest::setVar('name' , '');
JRequest::setVar('subject', '');
JRequest::setVar('email', '');

and add the lines for our new fields:

JRequest::setVar('from' , '');
JRequest::setVar('to' , '');

Scroll back up to the mail form and we can add the new fields to the email. I'm going to add them to the subject but the same thing applies if you want to add the information to the main email. The line we are going to edit is:

$subject = JRequest::getVar('subject', '') . ' [' .$config->getValue('fromname', '') . ']';

I'm going to add some fixed text aswell to make the subject more readable.

$subject =  ' [' .$config->getValue('fromname', '') .']' . JRequest::getVar('subject', '') . "   From: " . JRequest::getVar('from', '') . "   To: " . JRequest::getVar('to', '');

Now, when the form is sent, the email will have the subject as

[SiteName] John Doe Ref:PropertyName  From:12/12/2010  To:24/12/2012