Help with orderBy for events list
2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 5, 2017 (RSS)
By zip222 - June 30, 2017
I need assistance with the orderBy for an events list. I want upcoming events to be ordered by DATE ASC, but past events to be ordered by DATE DESC. Is there a way to do with this with just one listing, or do I need separate listings for each?
The upcoming/past status is set by a dropdown, but I could easily change that to something else if it's helpful.
thanks!
By Dave - July 5, 2017
Hi zip222,
Is this for a viewer search page? What about something like this?
// set orderBy
if (@$_REQUEST['status'] == 'past') { $orderBy = " `date` DESC "; }
else { $orderBy = " `date` ASC "; } // upcoming events
// load records from 'events'
list($eventsRecords, $eventsMetaData) = getRecords(array(
'tableName' => 'events',
'loadUploads' => true,
'allowSearch' => false,
'orderBy' => $orderBy,
));
Let me know if that works for you.
interactivetools.com