Content from Multiple Blogs with Dynamic Publishing
Multiblog is an indespensible plugin that allows you to display content from other blogs. Unfortunately, in its current version it doesn't work with dynamic publishing. A few days ago I was investigating the best way to duplicate MultiBlog's functions in the dynamic templating system. As it turns out, Movable Type's powerful dynamic templating system makes it easy to include content from other blogs.
With dynamic publishing all you need to do to pull content from other blogs is to change the blog context of the page. Every tag is parsed within a context which affects the content it outputs. For example, with the MTEntries tag the correct entries are outputted because Movable Type checks the blog context to ensure that only entries from the corresponding blog are displayed. Changing the blog context allows you to pull content from other blogs! Changing the blog context is quite easy; all you need to do is add the following code in your dynamic templates just before the areas where you wish to show content from different blogs:
<?php
$blog_id = X;
$this->stash('blog_id',$blog_id);
$blog = $this->mt->db->fetch_blog($blog_id);
$this->stash('blog',$blog);
?>
Make sure you replace X with the id of the blog you wish to change the context to include. One this code is in place, the tags that follow this block of code will pull content from the blog's id that has been specified in the $blog_id variable. For example, if I had the following in one of my dynamic templates:
<?php
$blog_id = 5;
$this->stash('blog_id',$blog_id);
$blog = $this->mt->db->fetch_blog($blog_id);
$this->stash('blog',$blog);
?>
<MTEntries lastn="5">
<MTEntryTitle><br />
</MTEntries>
I would get a listing of the 5 most recent entry titles from the blog with an ID of 5. As you're changing the context of the blog, unlike the MultiBlog plugin, you aren't limited to entries or comments, you can in fact include any content from the blog, i.e. entries, comments, trackbacks, category listings etc.
At the end of the area with content from another blog, you will want to switch the context back to the current blog so that the rest of your content is properly parsed. To do so, simply copy the context changing block of code and change the value of $blog_id.
So typically, when you want to display content from a different blog, your code will look something like this:
<?php
$blog_id = X;
$this->stash('blog_id',$blog_id);
$blog = $this->mt->db->fetch_blog($blog_id);
$this->stash('blog',$blog);
?>
[content e.g. MTEntries, MTComments]
<?php
$blog_id = Y;
$this->stash('blog_id',$blog_id);
$blog = $this->mt->db->fetch_blog($blog_id);
$this->stash('blog',$blog);
?>

Sah said:
on Dec 5, 2005 7:53 AM | Reply
Thanks for your good article! There is one thing I am not clear with: what if I would like to show the content in both the two of my blogs, but not only one of them? Do I write like this: "$blog_id = 1,4;"?
KO said:
on Dec 15, 2005 2:24 PM | Reply
I'm looking for the same thing as the above commenter - how to display content from multiple blogs - i.e have a list of recent entries which pulls the info from 3-4 blogs.
kevinyezbick said:
on Dec 21, 2005 9:14 PM | Reply
So -- does this actually merge the content? Placing the entries from multiple blogs in the order in which they were received -- or does this just place the content where the code is?
JK said:
on Jan 19, 2006 12:07 AM | Reply
This doesn't seem to work on MT 3.2. I got some error regarding invalid method on object. Maybe some interface has changed.
Doug said:
on May 3, 2006 7:09 PM | Reply
I was looking for the same thing on EE, where you can accomplish it by separating each blog with a "|" sign.
No idea whether it will work with MT.