Top and New Items RSS

Did I mention that I love PHP, oh yes.. I love Drupal too…

I’ve been on an kick to get caught up on my to-do list. On that list was getting RSS feeds working for catalog keyword searches as well as top and new item lists. Anyway, I was able to componentize the bit of code that generates an RSS bib-record summary and use it to provide customizable feeds for newly added and popular items.

Drupal has a nice bit of internal code that allows you to create an RSS stream. You essentially only need two functions:

<?php
 
header("Content-Type: text/xml");
 
/* Put together your content here */
 
$rss = '<rss version="2.0" xml:base="' . $base_url . '">';
foreach ($array_of_whatevers as $whatever) {
    $rssitems .= format_rss_item($item_title, $item_link, $whatever[content]);
}
$rss .= format_rss_channel($feed_title, $feed_url, $feed_description, $rssitems);
print($rss);
 
?>

Well, you get the idea.. My point is, Drupal is dreamy…


About this entry