Provide a hook for node-modules (blog, stories etc) to do some customization of RSS feed. Modules which wants to provide customization would provide module_feed_item($node) function where it will return format_rss_item().
e.g. the follow allows blog entries to return taxonomy and well-formed dc:creator and iso8601 dc:date.
function blog_feed_item($node) {
$link = url("node/view/$node->nid", NULL, NULL, 1);
$terms = array();
if (module_exist("taxonomy")) {
foreach (taxonomy_node_get_terms($node->nid) as $term) {
$terms = array_merge($terms,array("dc:subject" => $term->name));
break;
}
}
return format_rss_item($node->title, $link, $node->teaser,
array_merge($terms, array(
'dc:date' => encode_iso8601($node->changed),
'dc:creator' => $node->name,
need to add category/taxonomy info
))
);
}
| Comment | File | Size | Author |
|---|---|---|---|
| #1 | node.rss_0.diff | 2.04 KB | jseng |
| node.rss.diff | 2.04 KB | jseng |
Comments
Comment #1
jseng commentedoops..there i accidently inserted a dot in the patch (silly vim). here is the right patch.
Comment #2
drummThis is a duplicate of my pending patch:
http://drupal.org/node/view/6992
This patch doesn't do enough because RSS generation is still severely limited. Using the simple array structure for storing XML you can not make tags within tags, attributes, or tags with the same name. All of these can be hacked into the current model:
Which adds an id attribute in the space meant for only the tag name, which doubles as a way of getting multiple tags with the same name in using different IDs. The space meant for the cdata content contains tags.
This is not ideal at all because generating XML quickly becomes overly complex as places are added to and repurposed. Instead of waiting for PHP 5 which will have these built into the language, I think we need some Drupal API functions for XML handling. A nice parser will be part of my upcoming aggregator with API for making nodes from items, and will also be used by the FOAF support being worked on by Crschmidt, Jluster, Walkah, and Dries (its still in the design phase now).
The same nested array structure generated by the enhanced parser should be what the xml generator uses. I believe that this patch, and other patches which change generated XML such as RSS should wait until there is an API to standardize on.
Comment #3
jseng commentedIt is kind of different from http://drupal.org/node/view/6992 because 6992 patch extended the capability to add new xml fields whereas my patch allows you to modify the title, links or teaser.
For instance, it allows a module to specify that it wants full-entry in the RSS feed, not just the teaser. That cannot be done via 6992.
Comment #4
(not verified) commentedThe version string changed to 1.0, but where did the content change to 1.0?
Comment #5
jseng commentedthis patch is already outdated. the latest one should read 2.0 and have all the neccessary xml-ns.
but i rather we close this thread and i move on to pull out the RSS stuff from node.module instead.
Comment #6
drummSetting to closed as requested by jseng, and I agree. There are better ways to potentially solve this, for the next version after 4.5.