Difference between revisions of "How to add Inquiry Form to listing detail pages"
Line 114: | Line 114: | ||
<div class="jrFieldDiv"> | <div class="jrFieldDiv"> | ||
− | <label for="checkboxExample"><?php __t("Checkbox Example");?>: | + | <label for="checkboxExample"><?php __t("Checkbox Example");?>:</label> |
<?php echo $Form->checkbox('data[Inquiry][checkboxExample]',array('one'=>'One','two'=>'Two','three'=>'Three'),array('id'=>'checkboxExample'));?> | <?php echo $Form->checkbox('data[Inquiry][checkboxExample]',array('one'=>'One','two'=>'Two','three'=>'Three'),array('id'=>'checkboxExample'));?> | ||
Line 134: | Line 134: | ||
<div class="jrFieldDiv"> | <div class="jrFieldDiv"> | ||
− | <label for="selectExample"><?php __t("Select Example");?>: | + | <label for="selectExample"><?php __t("Select Example");?>:</label> |
<?php echo $Form->select('data[Inquiry][selectExample]',array('one'=>'One','two'=>'Two','three'=>'Three'),''/* pre-selected val */,array('id'=>'selectExample'));?> | <?php echo $Form->select('data[Inquiry][selectExample]',array('one'=>'One','two'=>'Two','three'=>'Three'),''/* pre-selected val */,array('id'=>'selectExample'));?> | ||
Line 155: | Line 155: | ||
<div class="jrFieldDiv"> | <div class="jrFieldDiv"> | ||
− | <label for="dateExample"><?php __t("Date Example");?>: | + | <label for="dateExample"><?php __t("Date Example");?>:</label> |
<?php echo $Form->text('data[Inquiry][dateExample]',array('id'=>'dateExample','class'=>'jrDate jr-date','size'=>50));?> | <?php echo $Form->text('data[Inquiry][dateExample]',array('id'=>'dateExample','class'=>'jrDate jr-date','size'=>50));?> |
Revision as of 14:14, 8 May 2015
Contents
Adding the inquiry form to detail pages
Inquiry button can be enabled in JReviews configuration:
The button will show up in listing info:
When someone clicks the button, the inquiry form will show up:
If you want to modify the layout of the Inquiry Form, modify this theme file:
- \com_jreviews\jreviews\views\themes\default\inquiries\create.thtml
The setting that determines who receives the inquiry e-mail is available in JReviews Cofiguration - Listings tab
Embedding the inquiry form directly to the page
To embed the inquiry form directly on the page instead of using the button and a popup, leave the inquiry setting disabled and instead add this code into the detail.thtml theme file where you want to show the form:
<?php echo $this->element("inquiry_widget");?>
Important:If you choose this option, you need to disable the email cloaking plugin in Joomla or make sure it runs before the JReviews plugin.
Guest listing submissions and inquiries
If you allow guests to submit listings without registering and you select the email to listing owner option, inquiries will not be sent out for listings submitted by guest users.
This is because guests are not listing owners and cannot even edit their own listing. Only registered users are considered listing owners.
If you wanted to allow inquiries for guests, you could use a custom email field for this purpose.
How to add more input fields to the form
Adding a phone number text field
Open the theme file:
- \com_jreviews\jreviews\views\themes\default\inquiries\create.thtml
and replicate the code of one of the other fields.
For example, to add a Phone number field, add this code:
<div class="jrFieldDiv"> <label for="jr-inquiry-phone"><?php __t("Your phone number");?>:<span class="jrIconRequired"></span> <span class="jr-validation-input jrValidation jrHidden"><?php __t("Please enter your phone number.");?></span> </label> <?php echo $Form->email('data[Inquiry][phone]',array('id'=>'jr-inquiry-phone','class'=>'jrText','size'=>50,'maxlength'=>100));?> </div>
The form will now look like this:
You will need to modify the controller file for the new field to be included in the E-mail:
- \com_jreviews\jreviews\controllers\inquiry_controller.php
If your new field is required, add it into the Required fields array (line 44):
// Required fields $inputs = array('from_name','from_email','message','phone');
At the bottom of the controller file find the part of code that constructs the Body of the E-mail and uncomment the line for the phone number:
$mail->Body = sprintf(JreviewsLocale::getPHP('INQUIRY_FROM'),$from_name) . "<br /><br />"; $mail->Body .= sprintf(JreviewsLocale::getPHP('INQUIRY_EMAIL'),$from_email) . "<br /><br />"; // Uncomment this line $mail->Body .= sprintf(JreviewsLocale::getPHP('INQUIRY_PHONE'),Sanitize::getString($this->data['Inquiry'],'phone')) . "<br />"; $mail->Body .= sprintf(JreviewsLocale::getPHP('INQUIRY_LISTING'),$listing['Listing']['title']) . "<br /><br />"; $mail->Body .= sprintf(JreviewsLocale::getPHP('INQUIRY_LISTING_LINK'),$link) . "<br /><br />"; $mail->Body .= $message;
Adding a checkbox to the inquiry form
Example code for the theme file:
<div class="jrFieldDiv"> <label for="checkboxExample"><?php __t("Checkbox Example");?>:</label> <?php echo $Form->checkbox('data[Inquiry][checkboxExample]',array('one'=>'One','two'=>'Two','three'=>'Three'),array('id'=>'checkboxExample'));?> </div>
Example code for the controller file:
$mail->Body .= sprintf(__t("Checkbox value example: %s",true),implode(' * ',Sanitize::getVar($this->data['Inquiry'],'checkboxExample'))) . "<br />";
Adding a select list to the inquiry form
Example code for the theme file:
<div class="jrFieldDiv"> <label for="selectExample"><?php __t("Select Example");?>:</label> <?php echo $Form->select('data[Inquiry][selectExample]',array('one'=>'One','two'=>'Two','three'=>'Three'),''/* pre-selected val */,array('id'=>'selectExample'));?> </div>
Example code for the controller file:
$mail->Body .= sprintf(__t("Select value example: %s",true),Sanitize::getString($this->data['Inquiry'],'selectExample')) . "<br />";
Adding a date field to the inquiry form
Example code for the theme file:
<div class="jrFieldDiv"> <label for="dateExample"><?php __t("Date Example");?>:</label> <?php echo $Form->text('data[Inquiry][dateExample]',array('id'=>'dateExample','class'=>'jrDate jr-date','size'=>50));?> </div>
Example code for the controller file:
$mail->Body .= sprintf(__t("Date value example: %s",true),Sanitize::getString($this->data['Inquiry'],'dateExample')) . "<br />";