Order of records

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

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!

By gregThomas - July 26, 2013

Hi,

To do this you'll have to remove the dragSortOrderBy field, and then sort the current blog records by creation date. To do this log into CMS Builder, then go to the section editors menu. Click the modify link for the section in question, this will take you to the section modification page. To be able to sort a list by date you need to first remove the dragSortOrder field. To do this click the erase link in the list of fields on the sections modification page. Once this has been done, click the sorting tab at the top of the section modification screen, in this tab you'll see an input called Order By, change this too:

createdDate DESC 

Now click the Save Details link and everything should be set up. When you go back to section you should find that all of the links are sorted in date order.

This change will also be applied to any getRecords lists on the front of your site as well.

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com