Advertisement:

Author Topic: Add more attributes to Real Estate Attributes Plugin [Solved]  (Read 573 times)

MarkT

  • Newbie
  • *
  • Posts: 17
Add more attributes to Real Estate Attributes Plugin [Solved]
« on: October 23, 2017, 10:40:34 pm »
Hi everyone

I'm using the Real State Attributes plugin by Osclass team.
I'd like to add some more attributes to the plugin (Some to to appear under the 'details' section of the listing amd some to appear under 'other characteristics').

Can anyone help me with this?

I've seen this question asked before, but none of the threads I've found have responses.

Any help would be great.

« Last Edit: November 01, 2017, 05:26:35 pm by MarkT »

MarkT

  • Newbie
  • *
  • Posts: 17
Re: Add more attributes to Real Estate Attributes Plugin
« Reply #1 on: November 01, 2017, 05:20:35 pm »
So I found the solution. Not too complicated but it is a lot of files that need to be edited.
hopefully it will help someone out.
OSClass version 3.7.4.

I suggest backing up your files and database before you get started, in case something goes wrong.

All the files I edited are in oc-content/plugins/realestate_attributes.
I also updated the database using PHPMyAdmin.

-----------------------------------------------------
Other Characteristics (the ones with ticks)

I will use the attribute 'Pool' as an example.

in index.php:

Around line 79 add
Code: [Select]
                     case 'pool':
                        Search::newInstance()->addConditions(sprintf("%st_item_house_attr.b_pool = %d ", DB_TABLE_PREFIX, $value));
                        $has_conditions = true;
                        break;


Around line 216 add
Code: [Select]
$pool           = Params::getParam('pool')!='' ? 1 : 0; Around line 240 add
Code: [Select]
'pool'          =>  $pool,  Around line 375 add
Code: [Select]
$pool           = (Params::getParam('pool')!='') ? 1 : 0; Around line 400 add
Code: [Select]
Session::newInstance()->_setForm('pre_pool'              , $pool );Around line 440 add
Code: [Select]
Session::newInstance()->_keepForm('pre_pool'); 
In struct.sql:

Around line 17 add
Code: [Select]
  b_pool BOOLEAN,

In ModelRealEstate.php:

Around line 139 add
Code: [Select]
'b_pool'            => $array['pool'], Around line 177 add
Code: [Select]
'b_pool'            => $array['pool'],
In item_edit.php:

Around line 240 add
Code: [Select]
<?php
                
if( Session::newInstance()->_getForm('pre_pool') != '' ) {
                    
$detail['b_pool'] = Session::newInstance()->_getForm('pre_pool');
                }
            
?>

            <li>
                <input style="width: 20px;" type="checkbox" name="pool" id="pool" value="1" <?php if(@$detail['b_pool'] == 1) { echo 'checked="yes"'; } ?>/> <label style="float:none;" for="pool"><?php _e('Pool''realestate_attributes'); ?></label>           
            </li> 

In helper.php:

Around line 159 add
Code: [Select]
if(@$detail['b_pool']) {
        $return['other_attributes']['b_pool'] = array(
                         'label' =>__('Pool', 'realestate_attributes')
                        ,'value' => true
                    );                 
    }

in search_form.php (If you want the attribute to be searchable):

Around line 208 add
Code: [Select]
            <li>
                <input <?php if(Params::getParam('pool') == ) { echo 'checked="yes"'; } ?> style="width:20px;" type="checkbox" name="pool" id="pool" value="1" /> <label for="pool"><strong><?php _e('Pool''realestate_attributes'); ?></strong></label>
            </li>

Using PHPMyAdmin (or database management tool of your choice) add the following column to osc_t_item_house_attr

Name: b_pool
Type: TINYINT:
Default: NULL

Here's a video to help you with this https://www.youtube.com/watch?v=jZ72GCGWPQg


Details (The attributes that display data like garages, rooms, Floor size etc)

I will use the attribute 'Levies' as an example.
It displays a price so it's declared as an integer. you will decide whether or not you use a string, Boolean or whatever based on your requirements (I used 'sqm' attribute as a reference)

in index.php:

Around lin 53 add
Code: [Select]
case 'levies':
                        if (preg_match('|([0-9]+) - ([0-9]+)|', $value, $match)) {
                            Search::newInstance()->addConditions(sprintf("%st_item_house_attr.i_levies >= %d AND %st_item_house_attr.i_levies <= %d", DB_TABLE_PREFIX, $match[1], DB_TABLE_PREFIX, $match[2]));
                            $has_conditions = true;
                        }
Around line 235 add
Code: [Select]
'levies'        =>  Params::getParam('levies'),   Around line 397 add
Code: [Select]
Session::newInstance()->_setForm('pre_levies'            , Params::getParam('levies') );    Around line 437 add
Code: [Select]
Session::newInstance()->_keepForm('pre_levies');
In struct.sql:

Around line 31 add
Code: [Select]
i_levies INT(6) UNSIGNED,
In ModelRealEstate.php:

Around line 132 add
Code: [Select]
'i_levies'          => $array['i_levies'], Around line 170 add
Code: [Select]
'i_levies'          => $array['levies'],
In item_edit.php:

Around line 107 add
Code: [Select]
<div class="row">
        <?php
            
if( Session::newInstance()->_getForm('pre_levies') != '' ) {
                
$detail['i_levies'] = Session::newInstance()->_getForm('pre_levies');
            }
        
?>

        <label for="levies"><?php _e('Levies''realestate_attributes'); ?></label>
        <input type="text" name="levies" id="levies" value="<?php echo @$detail['i_levies']; ?>" size="4" maxlength="6" />
    </div>

In helper.php:

Around line 76 add
Code: [Select]
    if(@$detail['i_levies'] != "") {
        $return['attributes']['levies'] = array(
                 'label' =>__('Levies ', 'realestate_attributes')
                ,'value' =>  @$detail['i_levies']
            );
   
   
    }

In view.php:

Around line 81 add
Code: [Select]
<li><input type="checkbox" name="custom-filter[levies]" <?php if(isset($custom['levies'])){ echo 'checked="checked"'; }?>><?php _e('Levies Range''realestate_attributes'); ?></li> 
Add the following column to osc_t_item_house_attr

Name: i_levies
Type: INT
Length: 6
Default: NULL

-----------------------------------------------------


This worked for me. Hopefully it will work for you :)