Dynamic List Order
5 posts by 3 authors in: Forums > CMS Builder
Last Post: March 19, 2010 (RSS)
By Perchpole - March 18, 2010
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
http://www.forrest.id.au/nutsnbolts/tables.php as an example.
Tim (toledoh.com.au)
Re: [Toledoh] Dynamic List Order
By Perchpole - March 19, 2010
Thanks for your suggestion but it doesn't really fit my requirements. I'm looking for something that will change the order of a list - possibly spanning several pages.
I was hoping we might be able to do it with a search query - something like...
?section=cars&orderBy=price
...or some such thing!
:0)
Perchpole
Re: [Perchpole] Dynamic List Order
By Chris - March 19, 2010
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.
Chris
Re: [chris] Dynamic List Order
By Perchpole - March 19, 2010
Yet again you never cease to amaze me!
Ossum.
:0)
Perch