Advertisement:

Author Topic: Conclusion brands and models in the preview ads  (Read 1938 times)

Vanhelsing911

  • Newbie
  • *
  • Posts: 1
Conclusion brands and models in the preview ads
« on: April 15, 2016, 12:03:18 pm »
Hello. Maybe the forum already has a solution to my problem, but I have not found. The attributes of the vehicle are displayed only when opening a specific ad. How do I display the make and model of car in the preview ads? It is necessary that when you view the list of ads was clear to which it refers car each of the ads.

osclasshero

  • Newbie
  • *
  • Posts: 15
Re: Conclusion brands and models in the preview ads
« Reply #1 on: November 01, 2017, 07:08:14 pm »
I hope you haven't given up on finding the solution for this. I've been working really hard to come up with a solution or at least get some help from a pro developer to come up with a solution.

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: Conclusion brands and models in the preview ads
« Reply #2 on: November 02, 2017, 03:19:51 am »
put this in functions.php of your theme
Code: [Select]
function cars_search_detail($item, $cat = null) {
    if ($cat != null && osc_is_this_category('cars_plugin', $cat) ) {
        $detail   = ModelCars::newInstance()->getCarAttr($item) ;

        if (count($detail) == 0) { return ; }

        $make     = ModelCars::newInstance()->getCarMakeById($detail['fk_i_make_id']);
        $model    = ModelCars::newInstance()->getCarModelById($detail['fk_i_model_id']);
        $car_type = ModelCars::newInstance()->getVehicleTypeById($detail['fk_vehicle_type_id']);

        $detail['s_make'] = '' ;
        if (array_key_exists('s_name', $make)) {
            $detail['s_make']  = $make['s_name'];
        }
        $detail['s_model'] = '' ;
        if (array_key_exists('s_name', $model)) {
            $detail['s_model']  = $model['s_name'];
        }
        $detail['locale']  = array() ;
        foreach($car_type as $c) {
            $detail['locale'][$c['fk_c_locale_code']]['s_car_type'] = $c['s_name'] ;
        }

        return $detail;
    }
}


for example you want to show the details in search results...
put this inside of the loop to load the details
Code: [Select]
$detail = cars_search_detail($osc_item_id(), osc_item_category_id());

then you can use all details in your preview ad like this
Code: [Select]
<?php if (!empty($carsDetail['s_make'])) { ?>
<div class="attribute">
    <div><?php _e('Make''cars_attributes'); ?></div>
    <div><?php echo @$carsDetail['s_make']; ?></div>
</div>
<?php ?>