Knowledgebase: v 4.x.x
How to add the sorting by Featured Ads in search results?
Posted by Lena Kosyakova on 18 November 2009 02:37 PM
Here is what you need to do:
1. open /system/user-scripts/classifieds/search_results_TemplateProcessorCharger.php, find the block:


} elseif ($sorting_field == 'id') {
$ids = join(", ", $this->found_listings_sids);
$sql = '
SELECT
listings.*
FROM
listings
WHERE
listings.sid IN ('.$ids.')
ORDER BY sid '.$sorting_order;

$listings_info = DB::query($sql);

}



and insert the following code afterwards:


elseif ($sorting_field == 'featured') {
$ids = join(", ", $this->found_listings_sids);
$sql = '
SELECT
listings.*
FROM
listings
WHERE
listings.sid IN ('.$ids.')
ORDER BY featured '.$sorting_order;

$listings_info = DB::query($sql);
}



2. open search_results.tpl and add the below line to a desired position:


<a href="?restore=1&sorting_field=featured&sorting_order={if $listing_search.sorting_order == 'ASC' && $listing_search.sorting_field == 'featured'}DESC{else}ASC{/if}">[[FormFieldCaptions!Featured]]</a>
{if $listing_search.sorting_field == 'featured'}
{if $listing_search.sorting_order == 'ASC'}<img src="{image}b_up_arrow.gif" alt="Up" />{else}<img src="{image}b_down_arrow.gif" alt="Down" />{/if}
{/if}

(308 votes)
This article was helpful
This article was not helpful

Comments (0)
Post a new comment 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please enter the text you see in the image into the textbox below. This is required to prevent automated registrations and form submissions.

Help Desk Software by Kayako Fusion