Sitewide RSS

Well, it looks like this weblog is becoming just a Movable Type how-to blog. Well, in keeping with that theme, here's a little "part two" companion piece for Doing your whole site with MT (one of my worst blog titles, ever).

Now that you've got your whole site MT-powered, what about your RSS feed? Chances are you, have one for your weblog, but what about one for everything? I've created one for my site, called sitewide.rss. It lets folks keep track of every update that happens to my site, whether it be part of my weblog or not.

To get it to work, you have to do a little bit of work. It's not much though, and once you've done it, it's easy to maintain.

Without further warning, here's the RSS template to do a sitewide RSS feed:

<MTSimpleTemplate>
# customize the following line by setting the value to the 
# blog IDs that you want to include in your RSS feed:
% SetVar name="blogs" value="1,2,3,4,5"
<?xml version="1.0" encoding="${PublishCharset}"?>
<rss version="2.0">

<channel>
<title>My Web Site RSS Feed</title>
<link>http://www.example.com/</link>
<description>Site-wide feed for My Web Site</description>
<language>en-us</language>
<managingEditor>someone@example.com</managingEditor>
<copyright>Copyright ${Date format="%Y"}</copyright>
<lastBuildDate>
% GlobalEntries include_blogs="${GetVar name='blogs'}" \
%     lastn_modified="1" sort_by="modified_on" \
%     sort_order="descend" {
${LastModified language="en" format="%a, %d %b %Y %H:%M:%S"} ${BlogTimezone no_colon="1"}
% } GlobalEntries
</lastBuildDate>
<pubDate>${Date language="en" format="%a, %d %b %Y %H:%M:%S"}
    ${BlogTimezone no_colon="1"}</pubDate>
<generator>http://www.movabletype.org/?v=
% Version
</generator>
<webMaster>brad@bradchoate.com</webMaster>
<ttl>60</ttl>

% GlobalEntries include_blogs="${GetVar name='blogs'}" \
%     lastn_modified="15" sort_by="modified_on" \
%     sort_order="descend" {
<item>
<title>${EntryTitle remove_html="1" encode_xml="1"}
</title>
<link>${EntryLink encode_xml="1"}
</link>
<description>${EntryBody encode_xml="1"}${EntryMore encode_xml="1"}</description>
<guid isPermaLink="true">${EntryPermalink}</guid>
<category>${BlogName encode_xml="1"}: ${EntryCategory encode_xml="1"}</category>
<author>${EntryAuthorEmail} (${EntryAuthor})</author>
<pubDate>${LastModified language="en" format="%a, %d %b %Y %H:%M:%S"}
    ${BlogTimezone no_colon="1"}</pubDate>
</item>
% } GlobalEntries

</channel>
</rss>
</MTSimpleTemplate>

Now, you'll need to customize the above template by setting the "include_blogs" attribute of the <MTGlobalEntries> tag to list the weblog ID's you wish to include in your RSS feed (this is listed in two places). You will also want to update the <title>, <link>, <description>, possibly <language>, and <managingEditor> elements. The above produces a "full" RSS feed. If you prefer to use excerpts, change the item-level <description> element to contain just: ${EntryExcerpt encode_xml="1"}

Installation

For each weblog you want to index in your sitewide RSS feed, create a new index template in that weblog. Give it a title of "Sitewide RSS" and put the above template code in there. The output filename can be anything. I named my "sitewide.rss". It should be marked to rebuild automatically.

Optional: You may want to enter a filename in the "Link this template to a file" field. This will help make updates to any cross-blog templates easier since you want to make this template identical across all the weblogs indexed. For example, you might choose "sitewide.tmpl" as the filename. By specifying the same filename for your "Sitewide RSS" template in each weblog, they will all be kept in synch.

Optional: If you use template modules to define macros and things like that, you can link those templates to files and include them using the IncludeEx plugin which will process the MT tags within the file (as opposed to the <MTInclude> tag which doesn't parse MT tags in files).

Requirements

Now to get this thing working, you'll need a few plugins (you knew that was coming):

  • Global Listings -- an excellent cross-blog entry listing solution by Stepan Riha. You could use my SQL plugin instead, but I chose this one since it works for any MT installation, not just those running on a SQL database.
  • Last Modified -- by Kevin Shay. Lets you grab the last modification date for your MT entries. The sitewide feed should be in order by last modified date since your entries will include pages that get regular updates. Listing by last modification will reveal those changes to your subscribers.
  • Simple Template -- well, not technically required, but the example above is uses it and I'm trying to get everyone else to use it too because I love it so.

If you've done it right, any new entries or updates made to any weblog that has this template will update your sitewide RSS feed.

TrackBack

TrackBack URL for this entry:
http://bradchoate.com/mt/feedback/tb/726

Listed below are links to weblogs that reference Sitewide RSS:

» sitewide rss from kiesows.de
mal wieder was bei Brad Choate gefunden. diesmal die möglichkeit einen etwas "größeren" feed anzubieten und zwar Sitewide RSS. eigentlich... [Read More]

» Sitewide RSS from ETC. Indulging my inner geek
Brad Choate: Sitewide RSS - as a companion to "Doing Your Whole Site in Movable Type", a feed for your... [Read More]

» sitewide rss from lovelinks
Create one RSS feed for multiple blogs: questions and ideas for Brad's Sitewide RSS.... [Read More]

» Sitewide RSS Feed from ecrosstexas: the texas blog
ecrosstexas now has a sitewide RSS 2.0 feed up and running. Thanks to Brad Choate to his fine example. Best of all, it validates!... [Read More]

» Meandering from TwoEyes.org
December Issue of 28MM. Particularly impressive is Dominic Turner's Westside Connection; a series of photos taken on Infa Red film in South Africa and left on file unintentionally exposed to extreme temperatures over time. Neat band creation tool at Cr... [Read More]

» Phew... from Haydur's World
I've just finished creating a global mutli blog RSS 2.0 feed for this site. Faced a lot of issues, but thankfully Brad Choate has a great starter entry on how to get this going, although I have an idea of... [Read More]

» Phew... from Haydur's World
I've just finished creating a global mutli blog RSS 2.0 feed for this site. Faced a lot of issues, but thankfully Brad Choate has a great starter entry on how to get this going, although I have an idea of... [Read More]

9 Comments

The Dead One said:

Hi Brad,

I'm afraid none of the links on this post seem to work! They all seem to be linked to just "http:///" ??

Brad Author Profile Page said:

Oops. A late night update to Textile will do that. All better now.

Kevin said:

So far every blog I listed in the “include_blogs” attribute of the tags, I should create a new index template as above. Correct? Or can I just create the template in one blog (out of seven) and go that way.

I created it in one and it seems to be pulling in all of them. I am not sure how frequently it will rebuild, though. Is that why each blog gets a copy?

If I do end up with seven copies of this template, which one should I direct people to?

Brad Author Profile Page said:

Kevin -- Yes, you would have a copy of that index template for each blog you're including. You should link the template to a file so that you can keep them all in sync a little easier. As for which to direct people to-- each index template should be writing to the same physical RSS file. So you would only have one file to direct people to. By adding an index template to each blog you're including, it insures that the RSS file is updated upon adding/editing any entry for any of those blogs.

Kevin said:

Brad - I've got all the templates going. They are all linked to a single file called "sitewide.tmpl". It is being updated on every post from every blog. Perfect.

How do I link the RSS to that template file?

Andrew said:

On a similar theme - is it possible to offer rss feeds for a single category only? And offer a selection of feeds covering individual categories as well as an all encompassing one.

Kevin said:

First, you -sir- are a bad mamma jamma. But you already knew that.

Second, sitewide comments feed?

Brad Author Profile Page said:

Be my guest to change the templates however you see fit.

I have installed the sitewide rss template and all I get is a blank page and this message when I rebuild the page:

MT::App::CMS=HASH(0x8326f20) Use of uninitialized value in concatenation (.) at lib/MT/Builder.pm line 121.

Please assist.
thanks
neil

About

This article was published on July 27, 2003 7:46 PM.

The article previously posted was Mozilla.

The next article is Reasons for sticking with Windows.

Many more can be found on the home page or by looking through the archives.

Powered by Movable Type