PDA

View Full Version : sort dealers by alphabetical order



Peter Jonsson
January 6, 2014, 01:00 PM
How do i change so at the dealers page the dealers get sorted alphabetical as standard?

Right now it's sorted by date as default.

Viktor
January 6, 2014, 01:24 PM
Hello Peter,

Go to ftp://includes>>classes>>rlAccount.class.php find method: searchDealers

and code:



else
{
$sql .= "`Date` " . strtoupper($data['sort_type']) . " ";
}


and replace to


else
{
$sql .= "`T1`.`Your_field_for_sorting_by_default` " . strtoupper($data['sort_type']) . " ";
}



save and check again.
WARNING: If you write incorrect field you will see mysql error on your site. That's why you should write correct field name from DB->fl_accounts table.

Peter Jonsson
January 7, 2014, 01:52 PM
Tried it and it don't seem to work. Nothing is changing.

Viktor
January 8, 2014, 05:17 AM
Hello Peter,

If you want I can check it on your site. Please send ftp access to my PM and I will change it on your site.

Ivan Amador
April 19, 2019, 05:18 AM
Hello Viktor,

I'm trying to sort dealers by "Listing_count" in Dealers page, but your suggested modification isn't working for me.

I used this code:


$sql .= "`T1`.`Listings_count` " . strtoupper($data['sort_type']) . " ";


Can you help me out with this?

Thanks!

Viktor
April 19, 2019, 10:28 AM
Where did you implement it? would you please send me a file or part of the code. I think you did something wrong.

Ivan Amador
April 19, 2019, 02:09 PM
Hello Viktor,

I'm using this code in ftp://includes>>classes>>rlAccount.class.php:


$sql .= "ORDER BY ";
if ($data['sort_by'] && $form[$data['sort_by']]) {
switch ($form[$data['sort_by']]['Type']) {
case 'price':
case 'unit':
case 'mixed':
$sql .= "ROUND(`T1`.`{$form[$data['sort_by']]['Key']}`) " . strtoupper($data['sort_type']) . " ";
break;

case 'select':
if ($form[$data['sort_by']]['Key'] == 'Category_ID') {
$sql .= "`T3`.`Key` " . strtoupper($data['sort_type']) . " ";
} elseif ($form[$data['sort_by']]['Key'] == 'Listing_type') {
$sql .= "`T3`.`Type` " . strtoupper($data['sort_type']) . " ";
} else {
$sql .= "`T1`.`{$form[$data['sort_by']]['Key']}` " . strtoupper($data['sort_type']) . " ";
}
break;

default:
$sql .= "`T1`.`{$form[$data['sort_by']]['Key']}` " . strtoupper($data['sort_type']) . " ";
break;
}
} else {
$sql .= "`T1`.`Listings_count` " . strtoupper($data['sort_type']) . " ";
}

$sql .= "LIMIT {$start}, {$per_page}";

Ivan Amador
April 25, 2019, 11:40 AM
Hello Viktor,

Do you know what should I edit to have the Dealers sorted by Listings_count by default?

Thanks!

Viktor
April 26, 2019, 03:56 AM
Implement the same line to another method: getDealersByChar located in the same class.

Ivan Amador
April 26, 2019, 05:47 AM
Perfect!

I replaced this code:


$sql .= "ORDER BY `Date` DESC ";

with this code:


$sql .= "ORDER BY `Listings_count` DESC ";

Thanks!