2 posts by 2 authors in: Forums > CMS Builder
Last Post: July 5, 2017   (RSS)

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.


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.

Dave Edis - Senior Developer