Well in my case I need to keep my types free for something else, so this suggestion wouldn't work.
To add fields to bedrooms you need to change multiple files so that it works when an agent posts a new property, so that it is displayed correctly, and for the search to work properly. I will try to not forget anything!
First, the agent post :
com_property/views/panel/tmpl/default_addproperty.php
search for
| Code: |
<tr>
<td class="key"><label for="bedrooms"><?php echo JText::_( 'Bedrooms' ); ?>:</label></td>
<td >
<input class="inputbox" type="text" name="bedrooms" id="bedrooms" size="3" maxlength="255" value="<?php echo $this->datos->bedrooms; ?>" />
</td>
</tr>
<tr>
|
it should be around line 1177(possibly different, I modified this file a lot)
You need to replace the line in the second <td>,(that one that starts with <input class="inputbox"..etc with the following :
| Code: |
<?php
if($this->datos->bedrooms == 1 ){$select0 = JText::_( 'selected="selected"' );}
if($this->datos->bedrooms == 2 ){$select1 = JText::_( 'selected="selected"' );}
if($this->datos->bedrooms == 3 ){$select2 = JText::_( 'selected="selected"' );}
if($this->datos->bedrooms == 4 ){$select3 = JText::_( 'selected="selected"' );}
if($this->datos->bedrooms == 5 ){$select4 = JText::_( 'selected="selected"' );}
?>
<select name="bedrooms" id="bedrooms" style="width:150px;">
<option <?php echo $select0;?> value="1"><?php echo JText::_( 'BEDROOM_ROOMS1' ); ?></option>
<option <?php echo $select1;?> value="2"><?php echo JText::_( 'BEDROOM_ROOMS2' ); ?></option>
<option <?php echo $select2;?> value="3"><?php echo JText::_( 'BEDROOM_ROOMS3' ); ?></option>
<option <?php echo $select3;?> value="4"><?php echo JText::_( 'BEDROOM_ROOMS4' ); ?></option>
<option <?php echo $select4;?> value="5"><?php echo JText::_( 'BEDROOM_ROOMS5' ); ?></option>
</select>
|
This will create a drop down menu with the selection of bedrooms of your choice. What's more important, this avoids having to change the database, as the values inserted are still going to be 1, 2, 3, 4,5 etc (so your search module will still be able to find them)
Now, the JTEXT:: refers to your joomla language file, and will print on the screen whatever you write in there, so the 2nd file to modify is this :
languages/en-GB/en-GB.ini (modifiy this one to make sure that the change is read on all areas of your site, not just under the com_propertie component pages)
Look at how the file is made, basically, all the words on the left of the "=" sign are IN CAPS. this is important to follow, so to create your words you coudl have something like :
| Code: |
BEDROOM_ROOMS1 = Studio
BEDROOM_ROOMS2 = 2 Rooms
BEDROOM_ROOMS3 = 3 Rooms
|
etc. If you have more then one language on your site, or if your main language is not en-GB, simply do the same change on other .ini files.
Now that this is done, you should be able to see in your agent panel that you're able to add values that are "Studio, 2 Rooms, 3 Rooms, etc.
The db inserts these values as 1, 2, 3, etc. This allows the search module to look for any value in the bedrooms field that is equal to, or bigger then 2.
To have the search module display "Studio" as the first choice:
modules/mod_prop_search_js/helper.php
find :
function getBedrooms()
around line 595
You should see something like :
| Code: |
$Md[0]->id_bedrooms=0;
$Md[0]->bedrooms=JText::_('Bedrooms');
$Md[1]->id_bedrooms=1;
$Md[1]->bedrooms=JText::_('1 or more');
$Md[2]->id_bedrooms=2;
$Md[2]->bedrooms=JText::_('2 or more');
$Md[3]->id_bedrooms=3;
$Md[3]->bedrooms=JText::_('3 or more');
$Md[4]->id_bedrooms=4;
$Md[4]->bedrooms=JText::_('4 or more');
$Md[5]->id_bedrooms=5;
$Md[5]->bedrooms=JText::_('5 or more');
|
simply change the values you want, for example 1 or more could be "Studio or Bigger"
Don't forget to add the exact same string in your language file:
STUDIO OR BIGGER = Studio or bigger, for each language.
If you don't add it to your language file, joomla will simply write what's inside the ('') of your JTEXT::_ call
That's it for this one. The last change you need to make is in:
components/com_properties/views/templates/list3.php
Search for :
| Code: |
<?php if($row->bedrooms){echo '<tr><td width="100%"><strong>'.JText::_('Bedrooms') .' :</strong></td><td width="100%">'. $row->bedrooms.'</td></tr>';} ?>
|
around line 654
Change it to :
| Code: |
<?php if($row->bedrooms = 1){echo '<tr><td width="100%"><strong>'.JText::_('Bedrooms') .' :</strong></td><td width="100%">'.JText::_('Studio') .'</td></tr>';}
else if ($row->bedrooms){echo '<tr><td width="100%"><strong>'.JText::_('Bedrooms') .' :</strong></td><td width="100%">'. $row->bedrooms.'</td></tr>';} ?>
|
This will check the value of the row bedrooms. If it is equal to 1, it means that this is a studio, and we don't it to print simply "1", we want it to print "Studio". If it's not 1, then it checks if there is a value in the bedrooms row, and if there is one, for example "3", it will print "3".
Let me know if you need any help with this, or if I'm missing something!