Change Sort Order

3 posts by 2 authors in: Forums > CMS Builder
Last Post: October 17, 2008   (RSS)

By avrom - October 16, 2008

Hi Dave,

I currently have a set of records displaying as a menu... Its the "schedules" menu on the left hand side:

http://www.firstaidforbc.com/course_schedules.php

Currently they are sorted by the order in the editor... date added. But I want to display them in order of their name. Here is the code I have on my web page:

list($course_schedulesRecords, $course_schedulesMetaData) = getRecords(array(
'tableName' => 'course_schedules',
'loadUploads' => '0',
'allowSearch' => '0',
));

And the menu part:

<?php foreach ($course_schedulesRecords as $record): ?>
<?php if ($record['display']): ?>
<p><a class="noLinkBold" href="<?php echo $record['_link'] ?>"><?php echo $record['course_name'] ?></a></p>
<?php endif ?>
<?php endforeach; ?>

Thanks Dave !! :))

Re: [virgodesign] Change Sort Order

By Dave - October 17, 2008

Hi Avrom,

By default CMS Builder will use the sorting you've setup under "Admin > Section Editors", but you can override that by entering a different sort order in the Code Generator or the view code itself.

Try adding this:
'orderBy' => 'course_name',

As in:
list($course_schedulesRecords, $course_schedulesMetaData) = getRecords(array(
'tableName' => 'course_schedules',
'orderBy' => 'course_name',
'loadUploads' => '0',
'allowSearch' => '0',
));

Hope that helps!
Dave Edis - Senior Developer
interactivetools.com