Dynamic List Order

5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 19, 2010   (RSS)

By Perchpole - March 18, 2010

Hello, Gang -

Here's a quickie...

How can I go about creating a dynamic sort mechanism?

Say I have a list of products. The page is coded in such a way as to orderBy = title. However, I want to give visitors the means to re-order the listing on the fly. You often see this done on e-commerce sites. Typically the page will have a drop-down menu allowing the visitor to choose from a range of ordering options. You may want to order the list by price or manufacturer - or just reverse what you see. (from Z to A).

Could this be done with CMSB?

:0)

Perch

Re: [Perchpole] Dynamic List Order

By Toledoh - March 19, 2010

If I have a table - I use jQuery to sort and filter...

http://www.forrest.id.au/nutsnbolts/tables.php as an example.
Cheers,

Tim (toledoh.com.au)

Re: [Perchpole] Dynamic List Order

By Chris - March 19, 2010

Hi Perchpole,

Yes, you can feed a form element into your orderBy for getRecords() like this:

$orderBy = 'default order by';
if (@$_REQUEST['orderBy']) {
$orderBy = $_REQUEST['orderBy'];
}
list($record, ) = getRecords(array(
'tableName' => 'cars',
'orderBy' => mysql_escape($orderBy),
));


I hope this helps. Please let me know if you have any questions.
All the best,
Chris

Re: [chris] Dynamic List Order

By Perchpole - March 19, 2010

Chris -

Yet again you never cease to amaze me!

Ossum.

:0)

Perch