Order of records

4 posts by 2 authors in: Forums > CMS Builder
Last Post: July 26, 2013   (RSS)

By Kittybiccy - July 25, 2013

How can I change how the order of records are displayed? I would like the newest first to automatically be at the to of the list (and page 1 where lots of records!) whereas at the moment it goes to the end. I've tried to adjust this in my section editor/sorting but it comes up with errors.

Thanks, Hannah

By gregThomas - July 25, 2013

Hi Hannah, 

Are you using a getRecords function to retrieve your records? If so you could use an orderBy key in it to ensure that the newest records are displayed first:

  // load records from 'blog'
  list($blogRecords, $blogMetaData) = getRecords(array(
    'tableName'   => 'blog',
    'loadUploads' => true,
    'allowSearch' => false,
    'orderBy'     => 'createdDate DESC'
  ));

This is just example code, so you'll have to make a few changes to get it working with your site. 

So the orderBy key would cause the records to be sorted by createdDate in decening order, which will display the newest records first.

Let me know if you have any questions.

Thanks

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By Kittybiccy - July 26, 2013

Hi Grey,

Sorry, I didn't mean records displaying on a page, I meant actually in the back end. I have a client who is a theatre company and all of their shows are added as a multi record. When she adds a new show it is added to the end of the list (they are on about 3 pages of shows when 100 per page are shown) and she has to manually drag it. She would like new ones to be displayed by order of entry, newest at top (of page 1).

Thanks!