Putting the mt:OtherBlog tag to work
There are a lot of new and useful tags in Movable Type 4.0. I'm slowly working my way through figuring some of them out and putting them to use. One of my favorites new tags is mt:OtherBlog. I actually hadn't played with it at all until a friend mention his frustration with figuring it out since the documentation for this tag is a little scant. So I spent a little time with it and am glad I did.
mt:Otherblog makes it easy to pull and post content from other blogs in your Movable Type installation. Previously I'd use a php include to pull content from another blog. Take a look at this site's footer. See where it says "from my Reading List"? That content is being pulled from my Reading List blog via a php include. I haven't switched it to the mt:OtherBlog method yet. The content from Correspondence Notes however is being pulled via mt:OtherBlog.
If you can do what mt:OtherBlog does with a php include what's the big deal? Efficiency and simplicity. For the php include method you must setup a special template for the first blog that spits out only the content you want to pull into the second blog. For Reading List the code in that template looks like this
<MTEntries lastn="1">
<a href="<$MTEntryLink$>"><$MTEntryTitle$></a> <br/>
<$MTEntryExcerpt$>
</MTEntries>
Then you must call up the content from that special template in your second blog's template
<?php require("/home/serverpath/html/books/specialtemplate.html"); ?>
And you of course need to make sure all the pages you want to display this content on have the .php extension, not .html.
With mt:Otherblog you don't have to do anything at all to the blog you want to pull content from and your standard .html extensions are just fine. All you have to do is figure out that blog's id number and then insert the following code (or some variation on it depending on what you specifically want to display) into the blog that will be displaying that content.
<mt:OtherBlog include_blogs="1>
<MTEntries lastn="2">
<a href="<$MTEntryLink$>"><
$MTEntryTitle$></a> <br/>
<$MTEntryExcerpt$>
</MTEntries>
</mt:OtherBlog>
The important variable for pulling content from other blogs is include_blogs="#". Key here is blogs, not blog. When I first started fooling with it I was trying <mt:OtherBlog include_blog="#"> with much frustration. Since you're using include_blogs you can of course pull from multiple blogs by simply
using comma separators (include_blogs="3, 15", etc).
Categories
Movable Type , technology4 Comments
Michelle published this on October 1, 2007.
A Useful Keyboard Shortcut for iTunes was the previous entry.
Working with Movable Type 4.0 Templates: Sidebar is the next entry.


Thanks again for your help. I use php includes a lot but it isn't the greatest solution for all clients. I'm thinking one drawback may be that updating the "other blog" doesn't also update the main blog. Which means you need to do a full (dreaded) rebuild. Am I wrong?
You're absolutely right J. So in cases where the main blog doesn't get updated frequently then a php include may still be the best way to go. On the flip side if you're adding to/editing/rebuilding the main blog regularly or more frequently than the secondary blog then mt:OtherBlog seems the way to go.
As the original creator of the MTOtherBlog plugin, which became the MultiBlog plugin, which was included with MT 4, I thought I should chime in here. :)
First of all, the OtherBlog/MultiBlog functionality has actually been rolled into a number of tags, including MTEntries. So you could compress your second example to something like the following:
<MTEntries lastn="2" include_blogs="1"> .... </MTEntries>Secondly, if you'll take a look at the plugin configuration for MultiBlog, you will see that it has the ability to define rebuild triggers for your blogs. So, if there is a chance to a secondary blog, an index rebuild of the main blog can be triggered, for example.
Hope that helps!
That's very interesting David. Thanks for sharing.