Movable Type Multi-Blogging

November 5th, 2009 | 0 Comments | Tech Stuff |

Back at the day job, there’s been a groundswell of interest in the idea of having posts from one of our many (many, many) blogs appear in other blogs, automatically. For example, Mary would like certain posts from Dave’s blog that may be of interest to hear readers to show up automatically on her blog.

We looked at a couple of kludgy and hack-ish ways of doing it with RSS feeds or whatever. But some digging into the intertubes gave some hints that there was in fact a Pretty Normal Way of doing this. As I’ve complained about before, the “official” documentation for MT is on the thin side. So what I found were a lot of disconnected clues on how to do some of these things, and had to connect the dots between them with a bit of educated guesswork.

Here’s my complete “Cookbook” on how to do it, using the Movable Type Enterprise Version.

Getting Started

You’ll need to know the blog ID numbers of the blogs you want to use. You can get this from the Blogs Overview screen (http://www.yoursite.com/mt/mt.cgi?__mode=list_blogs), and mousing over the name of the blog you want and reading the blogid=xx off of the status bar. The first implementation of this uses Mary’s blog (which we’ll refer to as the “target” blog) and Dave’s blog (the “source” blog), ID numbers 48 and 44, respectively.

Armed with this information, go into the Design::Templates section for the blog in which you want outside posts to appear in. In our example, we want posts from the source blog (Dave’s) to appear in the target blog (Mary’s), so we go into the Design::Templates section for Mary’s. From there, open the Main Index template. You’ll see a section that looks something like this:

<mt:Entries>
 <$mt:Include module="Entry Summary"$>
</mt:Entries>

We’re going to replace this with a multblog section that goes through the blogs we’ve selected, and does something similar.

<mt:MultiBlog>
 <mt:Entries include_blogs="44,48" sort_by="Release_Date" sort_order="descend">
  <$mt:BlogID setvar="blog_id"$>
  <mt:If name="blog_id" eq="44">
   <mt:EntryIfTagged tag="@mary">
     <$mt:Include module="Entry Summary Expanded"$>
   </mt:EntryIfTagged>
  <mt:Else name="blog_id" eq="48">
   <$mt:Include module="Entry Summary"$>
  </mt:Else>
  </mt:If>
 </mt:Entries>
</mt:MultiBlog>

Line-by-Line Explanation

Line 1 initiates the MultiBlog tag set, putting what follows into that context

Line 2 begins the mt:Entries loop, as in the original code, but with the added parameters to include blogs of ID 44 and 48 (note that you would include the target blog as well as the source blog), sorted in chronological order on Release_Date, descending from newest to oldest.

Line 3 sets an MT variable named blog_id, which will contain the number of the blog the Entry belongs to (44 or 48).

Line 4 tests to see which blog the Entry is from. If it’s from 44 (the source blog)…

Line 5 tests for a tag. We’re going to use tagging as a way to specify, from the source blog, which entries are to be republished. Without this test, all entries from the source blog will be included.

Line 6 is used if the post is tagged “@mary”. This tag by the way is arbitrary. We’re just using it here because it is a mnemonic. It pulls in a (new) template blog called “Entry Summary Expanded,” which will be explained below. You don’t have to use this, you can use the standard “Entry Summary” if you like.

Line 7 closes line 5

Line 8 checks to see, if the Entry is not 44, then it should be 48 (the current blog).

Line 9 If so, it uses the standard “Entry Summary” template block.

Line 10 closes line 8

Line 11 closes line 4 (the “If” loop)

Line 12 ends the Entries loop

Line 13 ends the Multblog context.

A Modified Entry Summary Block

The standard Entry Summary is modified so that

<mt:If tag="EntryAuthorDisplayName">
 By <span class="vcard author">
  <$mt:EntryAuthorLink show_hcard="1"$>
 </span>

becomes

Posted in <a href="<$mt:BlogURL$>"><$mt:BlogName$></a>

 By <span class="vcard author">
  <$mt:EntryAuthorLink show_hcard="1"$>
 </span>

The addition of the “Posted in…” block gives the name of the source blog, linked back to its home page. This is of course optional.

Triggers

Normally when you publish a post in the source blog, it simply republishes that blog. But when we’re cross-posting we want to have *both* blogs republish. The Multiblog plugin configuration section allows you to set up any number of triggers that will do this automatically.

In the target blog, go into Tools::Plugins, and click on the Multiblog link to open that section. Click on Settings, and you should see a green link to Create Rebuild Trigger. Click on it, and select the source blog from the list. Then make your choices from the two drop downs underneath the list. We’re using “When this publishes an entry” and “rebuild indexes.” Then click confirm.

You might wonder why not use the Multiblog Tag Default Arguments here to set 44 and 48, rather than specify them in the template code as we’ve done here. Those parameters can be set in the Multiblog tag itself, or here; but by doing so you can’t sort all the entries commingled chronologically. Instead, you’ll get all of the entries from 44 first, then the entries from 48, regardless of post date.

Making New Content Appear

Now you can begin publishing. Go into your source blog and create a new entry. At the bottom, put “@mary” (or whatever your tag is going to be) into the Tags block. Write your test post, and publish it. When you reload the home page of the target blog, you should see this new post appear there, complete with summary and images if you’ve provided them, linking back to the entry on the source blog.

Conclusion

The basic steps are

  1. identify your source and target blogs.
  2. modify the code in the target blog index template to include the new Multiblog block
  3. If you like, create a new expanded Entry Summary Block; otherwise, change the code to use the basic Entry Summary.
  4. Set up a trigger
  5. Begin using the tag on the source blog.

The list of blogs can be as long as you like. And you can apply tests to any and all of them using the logic in the MT tags system. Within them you can put posts into divs and apply different styles, test for other tags, or anything else you can cook up.

To make your blog really full-featured, apply the same coding changes to your monthly archive templates too. That way your cross-posts will live on indefinitely.

Tags: , ,

Leave a reply


Subscribe to comments with RSS or TrackBack to ' Movable Type Multi-Blogging '.

February 2010
S M T W T F S
« Jan    
 123456
78910111213
14151617181920
21222324252627
28  

New on Flickr

Pittsburgh
Yosemite Valley
Safeway
Surprise Lilies
Santa Cruz Pier
Tree
Gnarlly Pine Tree
Reflection