Live Product List Ordering Question
14 posts by 3 authors in: Forums > CMS Builder
Last Post: July 5, 2012 (RSS)
By Jason - July 3, 2012
Hi,
I think we have this sorted out. This is the code now on your page:
This uses an old mySQL trick where if you put +0 onto a field name, mySQL will treat the field as a number instead of a string.
Hope this helps.
I think we have this sorted out. This is the code now on your page:
$orderBy = @$_REQUEST['orderBy'];
if($orderBy=="sfbb_cheap_setup") {
//$orderBy = "CAST(sfbb_cheap_setup as DECIMAL(10,2))";
$orderBy = "sfbb_cheap_setup+0";
}
elseif($orderBy == "sfbb_cheap_setup DESC") {
$orderBy = "sfbb_cheap_setup+0 DESC";
}
list($isp_listRecords, $isp_listMetaData) = getRecords(array(
'tableName' => 'isp_list',
'perPage' => '15',
'where' => " category LIKE '%Superfast Broadband%' ",
'loadCreatedBy' => false,
'orderBy' => $orderBy,
));
This uses an old mySQL trick where if you put +0 onto a field name, mySQL will treat the field as a number instead of a string.
Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Live Product List Ordering Question
By mark99 - July 4, 2012
Sadly not. As I said before, the early code semi-worked, but it breaks my default alphanumeric ordering that is critical and so does the new code. So now we have a product with Z at the top of the list instead of ones that have the letter A or a number infront. Other product names are thus also mixed up in the default ordering too. That's why I raised the support request :) .
By Jason - July 4, 2012
Hi,
I added a small piece of code that default the order to "title" if not sorting by price.
Hope this helps,
I added a small piece of code that default the order to "title" if not sorting by price.
Hope this helps,
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Live Product List Ordering Question
By mark99 - July 5, 2012 - edited: July 5, 2012
It seems like perfection has now been achieved :) .