Advertisement:

Author Topic: add items in serch filter  (Read 2682 times)

carsangrah123

  • Jr. Member
  • **
  • Posts: 59
  • www.carsangrah.com
add items in serch filter
« on: April 11, 2014, 08:57:39 am »
Hi,
I have installed cars attributes, its working fine. But i want to add some extra attribute  like "Fuel" in search filter. I already have a database table which stores fuel details for all the listings. Can any one help me?

ianhaney

  • Full Member
  • ***
  • Posts: 197
Re: add items in serch filter
« Reply #1 on: October 22, 2014, 02:12:27 am »
Hi

Sorry was just seeing if you had this resolved as am looking to do the same

bstruik

  • Newbie
  • *
  • Posts: 27
Re: add items in serch filter
« Reply #2 on: December 09, 2014, 01:13:27 pm »
i also want to know
« Last Edit: December 09, 2014, 01:20:37 pm by bstruik »

Fernando36

  • Newbie
  • *
  • Posts: 16
Re: add items in serch filter
« Reply #3 on: November 25, 2015, 12:10:58 pm »
I had an issue like that.
I solve it when I delete this opition in car atributes and create this options and others one in custom atributes plugin.

envmar

  • Newbie
  • *
  • Posts: 8
Re: add items in serch filter
« Reply #4 on: February 24, 2016, 06:31:54 am »
For future reference:

Edit file: oc-content/plugins/cars_attributes/search_form.php

Around line 80, after closing div ( </div> ) of  the transmission section add:
Code: [Select]
   <div class="row one_input">
        <?php $fuel Params::getParam('fuel') ; ?>
        <h6 for="fuel"><?php _e('Fuel''cars_attributes'); ?></h6>
        <input style="width:20px;" type="radio" name="fuel" value="DIESEL" id="diesel" <?php if($fuel == 'DIESEL') { echo 'checked="yes"'; } ?>/> <label for="diesel"><?php _e('Diesel''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="fuel" value="GASOLINE" id="gasoline" <?php if($fuel == 'GASOLINE') { echo 'checked="yes"'; } ?>/> <label for="gasoline"><?php _e('Gasoline''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="fuel" value="ELECTRIC-HIBRID" id="electric-hibrid" <?php if($fuel == 'ELECTRIC-HIBRID') { echo 'checked="yes"'; } ?>/> <label for="electric-hibrid"><?php _e('Electric-Hibrid''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="fuel" value="OTHER" id="other" <?php if($fuel == 'OTHER') { echo 'checked="yes"'; } ?>/> <label for="other"><?php _e('Other''cars_attributes'); ?></label><br />
    </div>

So, this is what it'll look like including the transmission part:
Code: [Select]
    <div class="row one_input">
        <?php $transmission Params::getParam('transmission') ; ?>
        <h6 for="transmission"><?php _e('Transmission''cars_attributes'); ?></h6>
        <input style="width:20px;" type="radio" name="transmission" value="MANUAL" id="manual" <?php if($transmission == 'MANUAL') { echo 'checked="yes"'; } ?>/> <label for="manual"><?php _e('Manual''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="transmission" value="AUTO" id="auto" <?php if($transmission == 'AUTO') { echo 'checked="yes"'; } ?>/> <label for="auto"><?php _e('Automatic''cars_attributes'); ?></label>
    </div>
    <div class="row one_input">
        <?php $fuel Params::getParam('fuel') ; ?>
        <h6 for="fuel"><?php _e('Fuel''cars_attributes'); ?></h6>
        <input style="width:20px;" type="radio" name="fuel" value="DIESEL" id="diesel" <?php if($fuel == 'DIESEL') { echo 'checked="yes"'; } ?>/> <label for="diesel"><?php _e('Diesel''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="fuel" value="GASOLINE" id="gasoline" <?php if($fuel == 'GASOLINE') { echo 'checked="yes"'; } ?>/> <label for="gasoline"><?php _e('Gasoline''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="fuel" value="ELECTRIC-HIBRID" id="electric-hibrid" <?php if($fuel == 'ELECTRIC-HIBRID') { echo 'checked="yes"'; } ?>/> <label for="electric-hibrid"><?php _e('Electric-Hibrid''cars_attributes'); ?></label><br />
        <input style="width:20px;" type="radio" name="fuel" value="OTHER" id="other" <?php if($fuel == 'OTHER') { echo 'checked="yes"'; } ?>/> <label for="other"><?php _e('Other''cars_attributes'); ?></label><br />
    </div>

Edit file: oc-content/plugins/cars_attributes/index.php
Around line 47 after the transmission "break;" line add:
Code: [Select]
case 'fuel':
                    if( $value == 'DIESEL' || $value == 'GASOLINE' || $value == 'ELECTRIC-HIBRID' || $value == 'OTHER' ) {
                        Search::newInstance()->addConditions(sprintf("%st_item_car_attr.e_fuel = '%s'", DB_TABLE_PREFIX, $value));
                        $has_conditions = true;
                    }
break;

So it should now look like this:
Code: [Select]
               case 'transmission':
                    if( $value == 'AUTO' || $value == 'MANUAL' ) {
                        Search::newInstance()->addConditions(sprintf("%st_item_car_attr.e_transmission = '%s'", DB_TABLE_PREFIX, $value));
                        $has_conditions = true;
                    }
                break;
case 'fuel':
                    if( $value == 'DIESEL' || $value == 'GASOLINE' || $value == 'ELECTRIC-HIBRID' || $value == 'OTHER' ) {
                        Search::newInstance()->addConditions(sprintf("%st_item_car_attr.e_fuel = '%s'", DB_TABLE_PREFIX, $value));
                        $has_conditions = true;
                    }
break;
                default:
                break;


Note: This code is using the spelling "Electric-Hibrid" as in the original source code. If you've changed yours to reflect the North American spelling then then make sure this code reflects it. If you've added other fuel types then you'll need to add those options to this example.