Keep an article at top of page
9 posts by 5 authors in: Forums > CMS Builder
Last Post: February 12, 2008 (RSS)
By grauchut - January 10, 2008
Re: [grauchut] Keep an article at top of page
By Djulia - January 10, 2008 - edited: January 10, 2008
Here perhaps a solution :
http://www.interactivetools.com/forum/gforum.cgi?post=58753#58753
Djulia
Re: [grauchut] Keep an article at top of page
By Theo - January 10, 2008
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!
Re: [grauchut] Keep an article at top of page
By Dave - January 10, 2008
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.
interactivetools.com
Re: [Theo] Keep an article at top of page
By Dave - January 10, 2008
interactivetools.com
Re: [Dave] Keep an article at top of page
By Theo - January 10, 2008
(...hope no one remembers that I'm 34...)
Re: [Theo] Keep an article at top of page
By grauchut - January 10, 2008
Re: [Theo] Keep an article at top of page
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
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
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.
interactivetools.com