Keep an article at top of page

9 posts by 5 authors in: Forums > CMS Builder
Last Post: February 12, 2008   (RSS)

Re: [grauchut] Keep an article at top of page

By Djulia - January 10, 2008 - edited: January 10, 2008

Re: [grauchut] Keep an article at top of page

By Theo - January 10, 2008

Thanks for jumping in, Djulia!

If you didn't need the specific control mentioned in the other tutorial, you could have a simple checkbox to "bump" news items to the top. In fact, when you create a new "News" section, it will have this done automatically!

For existing editors, all you need to do is create a new checkbox called "featured", then set the orderBy value in your viewer to sort by date, with any items with the "featured" checkbox set sorted first:
$options['orderBy'] = 'featured DESC, date DESC';

And for another neat trick, you can keep your contributors from making ALL their submissions featured by making that checkbox an "admin only" field. Go to the Section Editors menu, click "Modify" for News, and then "Modify" for your featured field. Under "Advanced Options", setting the field to Admin Only will mean that non-admins can't decide which articles are featured!
Theo Wiersma

Re: [grauchut] Keep an article at top of page

By Dave - January 10, 2008

And for a checkbox, it's pretty much the same. Just add a checkbox field called 'featured', then add "featured DESC" to sort in descending order (so featured articles are first) to the beginning of the "List Order" field (under Section Editors) and to $options['orderBy'] in your "list viewer".

Let me know if you need more details.

One last note, because checkboxes save as "0" or "1", records you had before adding the field might sort differently (because you're sorting "1", "0", and "" (blank). If you already have a lot of records, you can either click "modify", "save" on each one to set the featured value to "0" or instead of "featured DESC" use "IF(featured,0,1)".

Sorry if I made that more complicated than it needed to be. :) Let me know if you need any clarification.
Dave Edis - Senior Developer
interactivetools.com

Re: [Theo] Keep an article at top of page

By Dave - January 10, 2008

Posted at 10:43... Always just one minute ahead of me aren't you Theo? :)
Dave Edis - Senior Developer
interactivetools.com

Re: [Dave] Keep an article at top of page

By Theo - January 10, 2008

You're slowing down now that you've hit 30, old man! Hah hah!

(...hope no one remembers that I'm 34...)
Theo Wiersma

Re: [Theo] Keep an article at top of page

Once again thanks for the help. Your company is truly great when it comes to support. Thanks Again Glenn
Glenn Rauchut (Owner) Emergency Designz

Re: [Theo] Keep an article at top of page

Hi, Theo.

Please can you tell me where your line of code should go if I want to list headlines in reverse order, so that the newest ones are always at the top? I currently have this on my list page:

<!-- STEP2: Display Record List (Paste this where you want your records to be listed) -->
<?php foreach ($listRows as $record): ?>
<P><STRONG><A HREF="<?php echo $record['_link'] ?>"><?php echo $record['title'] ?></A></STRONG><BR/>
<I>Added <?php echo date("l j F Y", strtotime($record['date'])) ?></I></P>
<P>
<?php endforeach ?>
<?php if (empty($listRows)): ?>
<!-- Display "No Records Found" Message -->
No records were found!<BR/>
<BR/>
<?php endif ?>
<BR/>
<!-- /STEP2: Display Record List -->

Regards, Nigel
Nigel Gordijk

Common Sense Design: User-focused Web design
Tel: 001 519 342 5348 | Web: www.commonsensedesign.net

Re: [NigelGordijk] Keep an article at top of page

By Dave - February 12, 2008

Hi Nigel,

In your 'orderBy' option just add 'DESC' after title. DESC is a MySQL keyword which means descending or reverse order. So it might look something like this:

$options['orderBy'] = 'featured DESC, date DESC';

Hope that helps, let us know if you need anything else.
Dave Edis - Senior Developer
interactivetools.com