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:
$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/

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,
---------------------------------------------------
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 :) .