RSS 0.92[1] allows for including taxonomy information in the feed. I propose that we upgrade format_rss_item() to include taxonomy information in each item.
Anyone know if this would break anything that consumes our feeds? If yes, can that consumer be upgraded to .92 compatibility?
[1] RSS 0.92: http://backend.userland.com/rss092
Comments
Comment #1
(not verified) commentedWould it be too hard to have Drupal provide feeds in .91, .92 and 1.0 RSS feed formats?
Comment #2
steele commentedI know that the args() can add a tag, but how to I add a nested tag?
I want to add an image tag to my rss.
I went in an hard coded it before I realized I could do it with args... doh.
What I would really like to see it this...
support for the more prevalent features of rss 2.0, like:
<pubDate></pubDate>
<lastBuildDate></lastBuildDate>
<category domain="syndic8"></category>
<category></category>
<generator></generator>
<docs></docs>
<ttl></ttl>
<image>
<title></title>
<url></url>
<link></link>
<width></width>
<height></height>
</image>
args handles everything but the image just fine, or am I missing something here?
I also want these to be generated dynamically from the user's profile so each user can set it themself, so is this something I should submit as an update myself or is there any interest in making this part of the core functionality?
Comment #3
steele commentedComment #4
steele commentedA little recursion will do ya good
proposed changes to handle nested elements
function format_rss_channel($title, $link, $description, $items, $language = "en", $args = array()) {
// arbitrary elements may be added using the $args associative array
$output .= "<channel>\n";
$output .= " <title>". drupal_specialchars(strip_tags($title)) ."</title>\n";
$output .= " <link>". drupal_specialchars(strip_tags($link)) ."</link>\n";
$output .= " <description>". drupal_specialchars($description) ."</description>\n";
$output .= " <language>". drupal_specialchars(strip_tags($language)) ."</language>\n";
// changes added for recursing elements
if (is_array($args)) {
$output .= create_node($args);
}
// end changes
$output .= $items;
$output .= "</channel>\n";
return $output;
}
function create_node($args) {
foreach ($args as $key => $value) {
if (is_array($value)) {
$output .= " <$key>\n". create_node($value) ." </$key>\n";
}
else {
$output .= " <$key>". drupal_specialchars(strip_tags($value)) ."</$key>\n";
}
}
return $output;
}
I am passing new info here from node.module in function node_feed() as follows:
at line 889 of cvs version
// added to support image elements
$rss_image = array("title"=> "SteelePrice.NET", "url"=> "http://steeleprice.net/images/spnet_logo_rss.gif", "link"=> "http://steeleprice.net", "width"=> "88", "height"=> "31");
$rss_args = array("copyright"=> "Copyright ©2003 H. Steele Price, IV, All rights reserved.", "image"=> $rss_image);
$output .= format_rss_channel($channel["title"], $channel["link"], $channel["description"], $items, $channel["language"], $rss_args);
$output .= "</rss>\n";
this results in my XML output looking like this:
- <rss version="0.91">
- <channel>
<title>SteelePrice.NET - trudging the road of happy coding</title>
<link>http://steeleprice.net</link>
<description>Live to code, don't code to live.</description>
<language>en</language>
<copyright>Copyright ©2003 H. Steele Price, IV, All rights reserved.</copyright>
- <image>
<title>SteelePrice.NET</title>
<url>http://steeleprice.net/images/spnet_logo_rss.gif</url>
<link>http://steeleprice.net</link>
<width>88</width>
<height>31</height>
</image>
- <item>
exactly what I wanted.
Comment #5
moshe weitzman commentedComment #6
drummYeah, I made an rss module. It was called export. I'll put it in cvs and release as soon as I have nonbroken websites that are mission critical. I'll also put up that other small filter module, I forgot what it was called. But this module will make it easy. Can we assign taxonomy terms to the whole site? There is a category tagh in channel.
Comment #7
moshe weitzman commentedComment #8
(not verified) commented