Reorder News Items

4 posts by 2 authors in: Forums > CMS Builder
Last Post: January 8, 2008   (RSS)

By Mohaukla - January 8, 2008

How do you reorder news items in the list view?

Is it possible to have them drag and drop as in the Sections Editor area?
Michael Moyers



Owner of Just Rite Design Inc. A growing network of professionals in web design, graphic design, flash development, programming, and audio & video productions.



"Due to budget constraints, the Light at the end of the tunnel will be temporarily out!"

Re: [justritedesign] Reorder News Items

By Theo - January 8, 2008 - edited: January 8, 2008

Michael,

Thanks for posting!

How do you reorder news items in the list view?


You want to update the $options['orderBy'] value in your list viewer page. This might currently be blank, or it might have one or more values already in, like:
$options['orderBy'] = 'date DESC';
Here are some common special sorting commands that you can use:

* fieldname DESC - The suffix "DESC" will sort the field in descending order (i.e. backwards). Attached to a date fieldname, this will sort the newest records first.
* fieldname+0 - sorts the field as a numeric value. Use this suffix if you are sorting numbers, but the sorting is coming out in a strange order (1, 2, 20, 21, 3, 4, 45, etc.).
* RAND() - Sorts the results in a random order. The results will be randomized every time the viewer is loaded.

If you need some help on some specific ordering requirements, please post and we'll see what we can do!


Is it possible to have them drag and drop as in the Sections Editor area?


Drag-sorting records is on the request list. I think it's a great idea, I think I brought it up to Dave while I was testing out 1.00 release candidate. :)
Theo Wiersma

Re: [justritedesign] Reorder News Items

By Theo - January 8, 2008

Would it be possible to actually number each of the items (for now - until the drag and drop functionality is implemented) by adding a field that we could issue a number to and then use the "order by" option to set them up. I would need help figuring out, if it is possible.

Absolutely!

1) Create a new text field for your news with the fieldname "orderPriority"
2) Set higher values for the ones with greater priority (i.e. the ones you want to show first) because you'll want to sort in descending order. If you sort low-to-high (ascending order), items with blank values for the field will be sorted first!
3) In your list viewer, set the orderBy option to this:
$options['orderBy'] = 'orderPriority+0 DESC, date DESC';
You'll probably also want to set this as your List Order field in the Section Editor, so that the news list in the program interface sorts the same way.


I don't have an ETA on drag-sort for records, but this should help you get by until then. Let me know if you need any further assistance with this!
Theo Wiersma