You are hereHome / Drupal / One feed module to rule them all

One feed module to rule them all


By Gerd Riesselmann - Posted on 05 November 2005

I found the build in feed support of Drupal to be a bit poor. It only offers RSS feeds, publishes only teasers, but not full text and doesn't allow to set an image for your feed. Atom support is missing and there is no comment feed. There are modules for both atom and comment feed, though.

That's why I decided to write a module for general feed handling purposes. The module is still very beta, however, it already powers this site's feeds. You can download it here. Be sure to read the INSTALL.txt file, since this module requires a hack to the node module.

These features are currently supported:

  • Feed image for RSS feeds
  • Both full text and teaser are published
  • Atom 1.0 feeds by just appending /atom to every feed (except taxonomy feeds). For example: /node/feed/atom gives the Atom 1.0 feed for new content.
  • Comment feeds for every node that has commenting enabled. These are located under node/[id]/feed and node/[id]/feed/atom
  • Handles If-modified-since requests to minimize bandwith even if caching is disabled
  • Turns relative links into absolute

To gain my totalfeeds module control over Drupal's build in feeds, the fucntion node_feed in the file node.module mut be changed. Just add four lines of code to the beginning of the function, so it looks like this:

<?php
function node_feed($nodes = 0, $channel = array()) {
 
// The following lines are to be added
 
if (function_exists("totalfeeds_feed")) {
     
totalfeeds_feed($nodes, $channel);   
      return;
  }
 
// End of totalfeeds hack   
 
.. original code follows ...
?>

The module is based upon my brain dead simple feed writer class.

Update: Version 0.2 has been uploaded. It checks data before writing it to the feed and adds three more options:

  • Define number of items in main and comment feed
  • Decide if either all nodes are included in main feed or only nodes promoted to front page
  • Change default type to either RSS or Atom for all feeds

Additionally, the width and height of image now must be entered.

Update: Version 0.3 has been uploaded. It adds missing translations and some bugfixes.

Update, September 7th, 2006: The module has been updated for Drupal 4.7. Additionally, two patches provided by Daniel Ellison have been incorporated. The module now supports feeds for all comments, and the dc:creator tag. You can download it here. The version for Drupal 4.6 is still available here.

Tags

I tried out this module - it looks good - but I started to see some errors in the logs. Probably around node privacy. Here's some samples:

Location /node/22/feed
Message You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0 query: select max(timestamp) as created from comments where nid = '22' WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','node_privacy_byrole_role1','node_privacy_byrole_user0')) in /var/www/therailfan/includes/database.mysql.inc on line 66.

Location /node/feed
Message Unknown table 'na' in where clause query: select max(changed) as changed, max(created) as created from node WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','node_privacy_byrole_role1','node_privacy_byrole_user0')) in /var/www/therailfan/includes/database.mysql.inc on line 66.

Hmm, weird...

Parts of that SQL are by my module, other aren't. Must be some other module hooking in on db_rewrite_query. However, db_rewrite_query isn't really needed, so I will remove it in version 0.2.

I upgraded to the newer version. Seems to be a different, but similar error this time. Maybe some interaction with the node_privacy_byrole module I am using.

Location /node/93/feed
Message Unknown table 'n' in on clause query: SELECT c.* FROM comments c INNER JOIN node_access na ON na.nid = n.nid WHERE (na.grant_view = 1 AND CONCAT(na.realm, na.gid) IN ('all0','node_privacy_byrole_role1','node_privacy_byrole_user0')) AND c.nid = '93' and c.status = 0 ORDER BY c.timestamp DESC LIMIT 0, 15 in /var/www/therailfan/includes/database.mysql.inc on line 66.

I see. Indeed a similar error, regarding comment retrieval SQL (which I copied from comments.module, though). I will have a look at it this evening.

I installed the TotalFeeds module on Drupal 4.6.5 using all four steps in the install.txt. Most of the features are working correctly (i.e. individual node feeds are working) but...

In the TotalFeeds settings, I set the limit to 30, but the feeds are still showing only 15 items.

Here's an example. I have over 130 posts in the category "events" at: http://www.chicagobean.com/taxonomy/term/74 And the feed is at: http://www.chicagobean.com/taxonomy/term/74/0/feed

Any idea why my feeds are still stuck at the 15 items limit?

I just installed your module, and it looks healthy. My main quest continues, though. I've been driving myself crazy for weeks now googling for a solution that will put the author's name with each item. I've seen it done (as on drupal.org/node/feed), but I think those sites are probably running 4.7 and I'm using 4.6. I know a little about php, but staring for long periods of time at node.module hasn't shown the way.

Anyway, any chance a future update will add this functionality?

Hi. Is this compatible with drupal 4.7?

Excellent module! Thanks so much for making this available. I've been scouring the 'net for something like this. Previously I was using the built-in Drupal RSS feeds, the Atom module and the CommentRSS modules. Yikes!

The only thing that CommentRSS has over your module is the ability to get a feed for any comment posted. I use it to be alerted on my Smartphone to all comments posted to my site. With your module I can get comment feeds for individual nodes, but not for the whole site. Is there a way to add this easily? Then I could scrap everything but TotalFeeds.

Don't worry about it. I added a site-wide comment feed myself. The URLs look like this:

http://www.syrinx.net/comment/feed
http://www.syrinx.net/comment/feed/atom

The only thing I don't have in there is the last update checking. I don't see how that would work with this feed anyway. But I've now done away with the Atom module and CommentRSS and use TotalFeeds exclusively.

Lance,

It may be a bit late, but hopefully you can still use this information. Beware: this involves fiddling with the TotalFeeds source code, so back up your original files! Also beware that there's a lot of line wrapping going on below, so just remember that each bit of code I posted should be on a single line, despite how it looks here.

All I did to get the author's name to appear was add this line:

<dc:creator><?php print (empty($item->authorName)) ? t("Unknown") : $item->authorName; ?></dc:creator>

to both atomwriter.cls.php (after line 65, above the </entry> line) and rsswriter.cls.php (after line 66, above the </item> line).

I also added this line:

xmlns:dc="http://purl.org/dc/elements/1.1/"

to the printTitle function in rsswriter.cls.php, between the two existing xmlns: lines. The atomwriter file already had this line in place, though it wasn't used for anything.

In addition, I removed the "Author Name:" prefix from comments, as the name is now recognized by RSS/Atom reader software so there's no need for it in the title anymore. The line to change is in totalfeeds.module, line 459. Change it from this:

$feedItem->title = $comment->name . ": " . $comment->subject;

to this:

$feedItem->title = $comment->subject;

Hope this helps. If anyone tries this and needs help just post here. I've subscribed to the comments on this post, thanks to Gerd. And Gerd, maybe you could roll all this into a new release! :)

Just a note to add to the above: it shouldn't really be necessary to make these changes to atomwriter.cls.php. It already contains a proper <author> tag. The feed reader I use (FeedReader) had a bug which missed that tag.

The hack should still be applied to rsswriter.cls.php, as RSS 2.0 insists that the <author> tag should contain only the author's email address, not their name. The <dc:creator> specifies only the author's name, not their email address. I also removed the line that generates the <author> tag from rsswriter.cls.php to make sure no email addresses were escaping.

Finally!

This is great - I have been looking for an all-inclusive feed module such as this for quite some time. Is there a Drupal thread on this?

It would be great to start posting this stuff on drupal.org and see if we can get a version going that doesn't modify the core code (node.module).

Great work!
Alex

Hi. I'd like to use this module with 4.7. When I follow the directions above, I can activate the module but /admin/settings/totalfeeds is blank.

My specific goal is to replace all RSS feeds on my site with ATOM feeds. (This is Tim Bray's and other's advice today, as every reasonable aggregator supports every feed format, so there is no need for duplicate formats. You should just pick one, and ATOM is the one with the most features and least bugs.)

I installed the ATOM module, which worked fine. But I couldn't find any way to turn off the RSS feeds. Also, I'd ideally like the ATOM feeds to be at example.com/blog/feed rather than example.com/blog/atom/feed, although that's not essential. But, it's generally poor form to put the protocol name in the URL.

Thanks in advance.

The unknown col error is a fault with drupal http://drupal.org/node/82513

But as I'm not sure aggrigator2 may not be working I might be back for your version.

Yeah, the unknown column error is the price one has to pay for query rewriting, I guess... A powerfull yet dangerous feature :-).

However, the issue has been hopefully resolved for this module since version 0.3, though not stated explicitly.

Hi, thanks for your module! I installed it
into my Drupal 4.7.3 site, and I'm seeing
an error:
warning: date() expects parameter 2 to be long, string given in /var/www/html/oehive.org/sites/default/modules/totalfeeds/feedwriter.cls.php on line 128.

I'm using ModPhp 5.1.2. (Provided by my
hosting service - I don't think I can change)

I just installed TotalFeeds yesterday. It seems to
be working fine otherwise. The error doesn't
show up all the time (I didn't see it until
this morning), and I don't know what triggers
it.

Hi,

It's working great, thanks, but what about supporting Live bookmarking? most users like it to be in their Firefox bookmarks...

Any chance on adding that feature? I used to have it with commentsrss so you might "borrow" the implementations from there. :)

Hi,

A nice feature to add is a combination of total feeds and related nodes so that a list of related nodes would show up on your feed to increase page views. I have such a module installed for Wordpress but haven't found such a hack for Drupal yet.

When I try to configure this module I get an error:

Fatal error: Call to undefined function form_textfield() in (path)/modules/totalfeeds/totalfeeds.module on line 104

Uh, the download file was linked wrong, the link still pointed to the 4.6-version.

Please download it again and install the new version.

I downloaded the new file, seems its still experiencing the same problem. The install doc says it requires 4.6.x so I wonder if the install is still the old version.

Fatal error: Call to undefined function form_textfield() in /drupal/drupal-4.7.3/modules/totalfeeds/totalfeeds.module on line 104

Sorry, it got overwritten by an old version again during last update. Now it is up to date, I promise! But to be on the safe side, try this link:

http://www.gerd-riesselmann.net/download/totalfeeds.4.7.zip

I've done a small tweak to the totalfeed module that adds related entries links at the end of each feed entry (see previous comment here requesting this...)

Available here :
http://filiation.blogspot.com/2007/01/drupal-add-related-links-to-your-r...

Nice stuff!

Any chance that you'll be porting this into Drupal 5 anytime soon?

Yeah,great work!I'd also like to know if you'll be porting this into Drupal 5 in the near future.

Drupal 5 is on my Agenda but not before the end of February.

i am sort of new to the rss thing.. but starting to get it... your module looks great surprised this isnt core for drupal.

so i have installed the module and i get rss updates on comments... but shouldnt i get updates if the node itself is editted?

also, a couple comments:

- i use the relativity module all over the place for creating child nodes... would be nice if i was notified on child additions (but i see post earlier that sounds like it might be about this)

- also, i think i read that rss is enablde for nodes with comments enabled.. asumming my initial question is correct.. i.e. i should get updates on content changes as well as comments.. then it doesnt make much sense to only enable with comments.

Peter Lindstrom
LiquidCMS - Content Management Solution Experts

I am also interested in the Drupal 5 version. On the basis I read above I am fully convinced.
Is there any way to get informed about updates, a newsletter or such? Or shall I follow this thread? :)

Janos

Getting this error after a fresh install:

Message mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /...../includes/database.mysql.inc on line 136.

I've done the hack, updated the modules, and this error is still posted to the administer main page. Any thoughts?

FYI: drupal 4.7

Nice work!

I'd love to see someone add Simple Sharing Extensions (http://msdn.microsoft.com/xml/rss/sse/) to Drupal's rss feed capability, which I think would enable groups to easily share event information with one another, without all the annoying manual calendar updating it takes now. Unfortunately, I'm not a developer, so it's beyond my skills.

You interested?

Hi,

I have just installed the module on our Drupal 4.7.x instance, and it looks fine, but I may have found a couple of errors:

- first, it looks like all "mailto" links get screwed.
A link to mailto:john@example.com is translated to http://www.example.com/ailto:john@example.com

- second, images embedded in post have some problem rendering on the feed:

Does anybody have any clue if these are solvable problems?

Thanks for the attention,

Giulio Cesare

Topics