Not a developer? Go to MovableType.com

Documentation

MultiBlog Template Tags

MultiBlog is a feature in Movable Type that allows content to be easily aggregated from multiple blogs or data sources within your Movable Type install to a single blog or page. The sources used for aggregating content can be configured through the Movable Type user interface via the MultiBlog settings area under the "Preferences > Plugins" area.

The sources can also be configured manually via your template code directly. A number of template tags support the blog_ids template tag attribute which is used for selecting the blogs across which to aggregate content. For example, the following template tag code sample will aggregate content across blogs with an ID of 1, 2 and 5:

<mt:Entries blog_ids="1,2,5">
   <p><mt:EntryTitle></p>
</mt:Entries>

The MultiBlog Template Tag

If you wish to set a context that includes multiple blogs that can span across multiple tags, one can use the <mt:Multiblog> template tag. This tag can encapsulate any number of tags that are "multiblog enabled" (see below) and will govern their respective scopes. For example, the following template tag code sample will output the last ten comments and entries for blogs with ids 1, 5 and 8.

<mt:MultiBlog include_blogs="1,5,8">
   <mt:Entries lastn="10">
      <p><mt:EntryTitle></p>
   </mt:Entries>
   <mt:Comments lastn="10">
      <p><mt:CommentBody></p>
   </mt:Entries>
</mt:MultiBlog>

Supported Attributes

If none of these attributes are provided, then Movable Type will default to searching the current blog context only.

MultiBlog Enabled Template Tags

The following tags support this syntax:

Back

Leave a Comment

10 Comments

Solomon

Solomon on October 2, 2007, 10:36 a.m. Reply

For those looking to aggregate posts from more than one blog (say, a main blog and a “link blog” with id’s 1 and 3 respectively for this example), here is the code I use for this that aggregates the posts, and allows you to use different layouts and css for the posts, depending on what blog they’re from:

<mt:entries include_blogs=”1,3”>

<MTDateHeader> <!— DateHeader Code —> </MTDateHeader>

<mt:SetVarBlock name=”BlogID”><mt:BlogID></mt:SetVarBlock>

<mt:If name=”BlogID” eq=”1”> <div class=”blogbody”> <!— Chunk of Code for displaying entries from blog 1 —> </mt:If>

<mt:If name=”BlogID” eq=”3”> <div class=”asideblogbody”> <!— Chunk of Code for displaying entries from blog 3 —> </mt:If>

</mt:entries>

jerame

jerame on February 5, 2008, 2:56 p.m. Reply

What about pulling all content from one blog and only specific content from another? Is this possible somehow? Right now I’m using invisible tags, but that means that even on the blog that I want to display all content, I have to put an invisible tag in the entries to get then to display. Is there an easier way?

Byrne Reese

Byrne Reese on February 5, 2008, 3:04 p.m. Reply

@Jerame - Movable Type does not currently support that kind of advanced logic. But it might be possible to with the assistance of the MT Collate plugin.

jerame

jerame on March 13, 2008, 6:48 p.m. Reply

@Byrne Reese - That’s too bad. Collate doesn’t appear updated for 4.x, but I’m not sure it will do exactly what I need.

What I want to do would look kinda like this:

The idea is that I can have 5, 10, 15 blogs (like localized versions for example) and if I wanted to display an entry from the main site, I could add a hidden tag to that entry and it would syndicate automatically. Or even the reverse would be great - having the localized blogs feed the main blog, like so:

…or something to that effect.

Something to think about for future versions. I would imagine it would be great for corporate bloggers as well. It would make cross posting and content sharing among many blogs infinitely easier.

Byrne Reese

Byrne Reese on March 13, 2008, 9:23 p.m. Reply

You know, Mark just created a much simpler version of MT-Collate called more simply “Collate.” It works with MT 4.1 - he has not created the documentation for it yet though. We should ping him and see what we can drum up!

Center Fox

Center Fox on March 17, 2008, 12:02 p.m. Reply

Is there a way to display the posts by date, instead of having it display each blogs topics grouped.

I’m displaying posts from 4 blogs. When using the tags mentioned above, my post displays the post by the blog name & not by date (newest on first).

How can I correct that?

Johnnie Wilcox

Johnnie Wilcox on September 1, 2009, 12:46 p.m. Reply

This is a follow-up to Solomon’s comment (#1). While that code does style each individual entry, in some cases it might be useful to indicate style for all the same-date entries as a block. If this is what you want, the following code can help.


<mt:MultiBlog>
    <mt:Entries lastn="20" include_blogs="x,y" sort_order="descend">
    <mt:SetVarBlock name="BlogID"><mt:BlogID></mt:SetVarBlock>
    <MTDateHeader>
        <mt:If name="BlogID" eq="x"><div class="x"></mt:If>
        <mt:If name="BlogID" eq="y"><div class="y"></mt:If>
        <h2><$mt:EntryDate$></h2>
    </MTDateHeader>
        <$mt:Include module="Entry Body"$>
    <MTDateFooter>
        </div>
    </MTDateFooter>
    </mt:Entries>
</mt:MultiBlog>

Pierre-Henri Lavigne

Pierre-Henri Lavigne on January 14, 2010, 9:16 p.m. Reply

This plugin is quiet great, but I can’t find the written documentations to know which templates are supported, both for MT4 and MT5. With the latest version shipped with MT5, every Archive / WebPages templates are still not supported ? Only Main index ? Thank you for clearing the situation please

Maarten Schenk

Maarten Schenk on March 13, 2010, 1:33 p.m. Reply

I’ve written a little article about how to integrate entries from multiple blogs in one date-ordered list: http://www.movabletips.com/2010/03/listing-entries-from-multiple-movable-type-blogs-sorted-by-date.html

This also works if you want to have entries from one category from one blog, and entries from another from a different blog, or with specific tags…

It works for MT4 and MT5 and no plugins are required.

Ann Ray

Ann Ray on October 15, 2012, 9:43 a.m. Reply

Couldn’t get this to work until I changed it from name=”BlogID” to tag=”BlogID”. Great for my FeedBurner URLs:

<mt:If tag=”BlogID” eq=”8”><$mt:Var name=”feedburner” value=”Whatever”$> </mt:If$>

<link rel=”alternate” type=”application/rss+xml” title=”<$mt:BlogName encode_html=”1”> via FeedBurner” href=”http://feeds.feedburner.com/<$mt:Var name=”feedburner”$>” />