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).
4 Comments