We've just got running a great video RSS feed from the video.module, thanks to those developers over there: http://drupal.org/node/25230

I've just used this module to publish our RSS feed to third party aggregators like iTunes and FireANT and stuff. Plug this into an RSS browser and you'll see: http://www.cctvcambridge.org/videofeed

Now I would like to sort that feed so that one particular video node is always at the top of the RSS feed. We have a live webstream that channels through a QuickTime file and when our RSS feed is viewed in one of these browsers I want that webstream node to always sit at the top.

Is this something that can be done in code or is it easy enough to flat out lie about the date of the node so that it shows up at the top? Is there an elegant way to do it? I am not a PHP speaker so thats why I'm asking you kind folks.

Thanks for any and all of your help!

Sean
http://www.cctvcambridge.org

Comments

paddy_deburca’s picture

Update your node.module as follows

  /**
   * A generic function for generating RSS feeds from a set of nodes.
   *
   * @param $nodes
   *   An object as returned by db_query() which contains the nid field.
   * @param $channel
   *   An associative array containing title, link, description and other keys.
   *   The link should be an absolute URL.
   */
  function node_feed($nodes = 0, $channel = array()) {
    global $base_url, $locale;

    if (!$nodes) {
-     $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.created DESC'), 0, variable_get('feed_default_items', 10));
+     $nodes = db_query_range(db_rewrite_sql('SELECT n.nid FROM {node} n WHERE n.promote = 1 AND n.status = 1 ORDER BY n.sticky DESC, n.created DESC'), 0, variable_get('feed_default_items', 10));
    }

Notice the added "n.sticky DESC," following the ORDER BY clause? This should give your RSS feeds stickies.

Paddy.

http://deburca.org, and http://amadain.net

seaneffel’s picture

Will this work for the RSS 2.0 form that is published by video.module too? And if so, is there a chance that this could be included in the next drupal release as standard?

Sean
Cambridge Community Television
http://www.cctvcambridge.org

boris mann’s picture

RSS has no concept of order whatsoever. The receiving application is what determines display order. The actual RSS output might be ordered, but it's just a way of transmitting X number of feed items.

So, in short, it's not part of the RSS standard, so it won't be included in any Drupal core.

seaneffel’s picture

Maybe it makes sense to put this code together with some others as a plug in. Needs change on their own, standards don't, so I wouldn't rule it out based on standards alone.

Sean
Cambridge Community Television
http://www.cctvcambridge.org

morbus iff’s picture

Not entirely correct, Boris: RSS 1.0 supports sequences, per RDF. Ultimately, however, that's irrelevant: I know of no reader that actually supports it properly (as logic - they'll parse it just fine), and Drupal doesn't produce 1.0. Anyways, seanjuan, stickies don't make sense for an entirely different reason: most readers keep track of which items a user has read - some do this based on title, URL, [link], [permaLink], or what have you. Even if there was an approved method of order, most readers would show the user your first item once, and then never again, assuming it was duplicate data (assuming the data did, in fact, stay the same).

http://www.disobey.com/
http://www.gamegrene.com/

paddy_deburca’s picture

In the admin/settings one can set the number of items per feed and the default is 10.

By feeding sticky items first we are more consistent with the display of the home page.

This also means that an important items can remain on the RSS feed long after it would normally have fallen off.

Paddy.

http://deburca.org, and http://amadain.net

seaneffel’s picture

So for example, Democracy NOW's RSS feed always contains a certain item that never rolls off, the item about their daily news being translated into spanish.

http://www.democracynow.org/democracynow.rss

Does this mean that they are posting or editing this article for every single day or is there some other method that keeps this article at the top? Can someone explain this?

This is what I want for one of our media items, the one that links to our 24/7 video feed from our television station.

Sean
Cambridge Community Television
http://www.cctvcambridge.org

paddy_deburca’s picture

Sticky items remain at the top of the node list - sticky items first then non-sticky items.

Normally, the CSS class 'sticky' is appended to the class attribute for sticky items. So by creating a .sticky { ... } statement in your style.css you can even present sticky items differently.

With the update to node_feed to feed sticky items first also means that the RSS reader would always be fed the stick items - but it may be that the RSS reader will order the items chronologically.

Paddy.

http://deburca.org, and http://amadain.net