Tip: Combining multiple blogs into a single feed

I will be using Movable Type's default RSS 2.0 template, simply for size reasons. These template changes can apply just as easily to Atom feeds or any other feed template you can come up with.

First, here is the default template:

<?xml version="1.0" encoding="<$MTPublishCharset$>"?>
<rss version="2.0">
   <channel>
      <title><$MTBlogName remove_html="1" encode_xml="1"$></title>
      <link><$MTBlogURL$></link>
      <description><$MTBlogDescription remove_html="1" encode_xml="1"$></description>
      <language><$MTBlogLanguage ietf="1"$></language>
      <copyright>Copyright <$MTDate format="%Y"$></copyright>
      <lastBuildDate><MTEntries lastn="1"><$MTEntryDate format_name="rfc822"$></MTEntries></lastBuildDate>
      <generator>http://www.sixapart.com/movabletype/?v=<$MTVersion$></generator>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs>

      <MTEntries lastn="15">
      <item>
         <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
         <description><$MTEntryBody encode_xml="1"$></description>
         <link><$MTEntryPermalink encode_xml="1"$></link>
         <guid><$MTEntryPermalink encode_xml="1"$></guid>
         <category><$MTEntryCategory remove_html="1" encode_xml="1"$></category>
         <pubDate><$MTEntryDate format_name="rfc822"$></pubDate>
      </item>
      </MTEntries>
   </channel>
</rss>

Next, we will substitute MTMultiBlogEntries for MTEntries. This will get the last 15 entries from the combined entry list of all of the included blogs. There are a number of options that will be available in the next major release of MultiBlog, but for now we will simply make use of the include_blogs attribute. In this example, the ids of the three blogs we wish to integrate will be 7, 21, and 24.

The blog ids can be retreived simply by going to the main menu for the particular blog and making note of the blog_id parameter in the URL.

Here are the modified portions of the template:

      <lastBuildDate><MTMultiBlogEntries include_blogs="7,21,24" lastn="1"><$MTEntryDate format_name="rfc822"$></MTMultiBlogEntries></lastBuildDate>

      <MTMultiBlogEntries include_blogs="7,21,24" lastn="15">
      <item>
         <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
         <description><$MTEntryBody encode_xml="1"$></description>
         <link><$MTEntryPermalink encode_xml="1"$></link>
         <guid><$MTEntryPermalink encode_xml="1"$></guid>
         <category><$MTEntryCategory remove_html="1" encode_xml="1"$></category>
         <pubDate><$MTEntryDate format_name="rfc822"$></pubDate>
      </item>
      </MTMultiBlogEntries>

That's it!

For bonus points, let's add some information to the feed. We will add the blog name to the entry title so that entries from the different blogs can be distinguished.

<title><$MTBlogName remove_html="1" encode_xml="1"$>: <$MTEntryTitle remove_html="1" encode_xml="1"$></title>

Or, if you only want entries that are not from the current blog to have the blog names prepended to the titles:

<title><MTMultiBlogIfNotLocalBlog><$MTBlogName remove_html="1" encode_xml="1"$>: </MTMultiBlogIfNotLocalBlog><$MTEntryTitle remove_html="1" encode_xml="1"$></title>

If there are any other integration issues I can address, please let me know.

2 Comments

Tried and tried again, but i keep getting this error when rebuilding:

Can't call method "parent_categories" without a package or object reference at lib/MT/Template/ContextHandlers.pm line 3234.

i'm using MT 3.2, if that makes a difference.

Joshua,

Did you ever figure out what was causing the error you mentioned? I'm getting the same thing.

Leave a comment

Recent Entries

  • Plugin Writing 101

    So, I’m planning on writing up some entries about various aspects of plugin development. While I have a couple topics already in mind, I thought...

  • The Olympics Make Me Want To Compete Again

    Every time the Olympics come around (most the summer ones) I always start to delude myself into thinking I could complete once again in the...

  • Minimalist plugins are fun!

    Last night I whipped up one of the smallest plugins I’ve ever written. It is so small in fact that I was able to stuff...

  • Feedburner Widget on MT News

    Movable Type News A WordPress 2.5 Upgrade Guide: And of course there are lots of third-party plugins for the MT dashboard, to integrate statistics and...

  • AD&D Monster Stats for the Presidential Canditates

    Charles Stross (scifi author, D&D nerd, and former perl columnist) posted Politics as she is Played with 3d6: The recent death of Gary Gygax, who...

Close