Explicitly ordering a view before rendering

Events happening in the community are now at Drupal community events on www.drupal.org.
Posted by IbnDrupal on March 9, 2009 at 10:43pm

I have a view that selects several nodes by certain sort criteria, say date. Some of these nodes have been labelled sticky.

I would like to reorder the list so that the first sticky appears at the top of the view, and the remaining nodes remain in date order.

Is this possible?

I've tried doing this at the template level but have no idea how to, and I don't think creating a sort handler will help as i'm not sure how I would create such a query.

Any help would be much appreciated.

NOTE: If you are interested in what functionality i ultimately want, I am essentially designing the frontpage of a newssite. The frontpage will contain all stories in date order (recent at the top) however I should be able to select a main story which should appear at the top regardless of its date.

Comments

In the sort section of the

Posted by Scott Reynolds on March 10, 2009 at 5:26am

In the sort section of the Views UI, add the Sticky sort before the created sort. This has the affect of ordering by Sticky first then by date.

Very common use case.

Thanks but it is a more complicated then that

Posted by IbnDrupal on March 10, 2009 at 12:12pm

Scott,

Thanks for taking the time to respond. Unfortunately my case is a bit more complicated, as I want only the very FIRST (the latest) sticky to go at the top, all remaining articles including any remaining stickies to be sorted by date.

I have found the following which may help me, but lets see. http://www.davidnewkerk.com/book/121

then you want nodequeue

Posted by Scott Reynolds on March 11, 2009 at 12:00am

then you want nodequeue module http://drupal.org/project/nodequeue

originally written by Earl, creator and maintainer of Views.

edit: oops should have click that link. Yes use nodequeue. If you need that fine grain control that is the way to go.

It sounds to me like this

Posted by dwees on March 10, 2009 at 4:34pm

It sounds to me like this might be accomplished with two views. One view returns the most recent stickied post only, and the other view sorts the same material by date. Hide the first view when you are on the second page of results, etc... and I think you are done.

Thank you all.

Posted by IbnDrupal on March 12, 2009 at 5:31pm

Thanks all,

I adopted Scott's final solution.

David (Keyz) wrote a great tutorial on how to do this which can be found here: http://www.davidnewkerk.com/book/121

Thanks!

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

AltStyle によって変換されたページ (->オリジナル) /