Movable Type Multi-Blogging

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

Back at the day job, there’s been a groundswell of inter­est in the idea of hav­ing posts from one of our many (many, many) blogs appear in other blogs, auto­mat­i­cally. For exam­ple, Mary would like cer­tain posts from Dave’s blog that may be of inter­est to hear read­ers to show up auto­mat­i­cally on her blog.

We looked at a cou­ple of kludgy and hack-ish ways of doing it with RSS feeds or what­ever. But some dig­ging into the inter­tubes gave some hints that there was in fact a Pretty Nor­mal Way of doing this. As I’ve com­plained about before, the “offi­cial” doc­u­men­ta­tion for MT is on the thin side. So what I found were a lot of dis­con­nected clues on how to do some of these things, and had to con­nect the dots between them with a bit of edu­cated guesswork.

Here’s my com­plete “Cook­book” on how to do it, using the Mov­able Type Enter­prise Version.

Get­ting Started

You’ll need to know the blog ID num­bers of the blogs you want to use. You can get this from the Blogs Overview screen (http://​www​.your​site​.com/​m​t​/​m​t​.​c​g​i​?​_​_​m​o​d​e​=​l​i​s​t​_​b​l​ogs), and mou­s­ing over the name of the blog you want and read­ing the blogid=xx off of the sta­tus bar. The first imple­men­ta­tion of this uses Mary’s blog (which we’ll refer to as the “tar­get” blog) and Dave’s blog (the “source” blog), ID num­bers 48 and 44, respectively.

Armed with this infor­ma­tion, go into the Design::Templates sec­tion for the blog in which you want out­side posts to appear in. In our exam­ple, we want posts from the source blog (Dave’s) to appear in the tar­get blog (Mary’s), so we go into the Design::Templates sec­tion for Mary’s. From there, open the Main Index tem­plate. You’ll see a sec­tion that looks some­thing like this:

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

We’re going to replace this with a mult­blog sec­tion that goes through the blogs we’ve selected, and does some­thing sim­i­lar.

<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 Expla­na­tion

Line 1 ini­ti­ates the Multi­Blog tag set, putting what fol­lows into that context

Line 2 begins the mt:Entries loop, as in the orig­i­nal code, but with the added para­me­ters to include blogs of ID 44 and 48 (note that you would include the tar­get blog as well as the source blog), sorted in chrono­log­i­cal order on Release_Date, descend­ing from newest to oldest.

Line 3 sets an MT vari­able named blog_id, which will con­tain the num­ber 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 tag­ging as a way to spec­ify, from the source blog, which entries are to be repub­lished. With­out 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 arbi­trary. We’re just using it here because it is a mnemonic. It pulls in a (new) tem­plate blog called “Entry Sum­mary Expanded,” which will be explained below. You don’t have to use this, you can use the stan­dard “Entry Sum­mary” 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 cur­rent blog).

Line 9 If so, it uses the stan­dard “Entry Sum­mary” tem­plate block.

Line 10 closes line 8

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

Line 12 ends the Entries loop

Line 13 ends the Mult­blog context.

A Mod­i­fied Entry Sum­mary Block

The stan­dard Entry Sum­mary is mod­i­fied 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 addi­tion of the “Posted in…” block gives the name of the source blog, linked back to its home page. This is of course optional.

Trig­gers

Nor­mally when you pub­lish a post in the source blog, it sim­ply repub­lishes that blog. But when we’re cross-posting we want to have *both* blogs repub­lish. The Multi­blog plu­gin con­fig­u­ra­tion sec­tion allows you to set up any num­ber of trig­gers that will do this automatically.

In the tar­get blog, go into Tools::Plugins, and click on the Multi­blog link to open that sec­tion. Click on Set­tings, and you should see a green link to Cre­ate Rebuild Trig­ger. Click on it, and select the source blog from the list. Then make your choices from the two drop downs under­neath the list. We’re using “When this pub­lishes an entry” and “rebuild indexes.” Then click confirm.

You might won­der why not use the Multi­blog Tag Default Argu­ments here to set 44 and 48, rather than spec­ify them in the tem­plate code as we’ve done here. Those para­me­ters can be set in the Multi­blog tag itself, or here; but by doing so you can’t sort all the entries com­min­gled chrono­log­i­cally. Instead, you’ll get all of the entries from 44 first, then the entries from 48, regard­less of post date.

Mak­ing New Con­tent Appear

Now you can begin pub­lish­ing. Go into your source blog and cre­ate a new entry. At the bot­tom, put “@mary” (or what­ever your tag is going to be) into the Tags block. Write your test post, and pub­lish it. When you reload the home page of the tar­get blog, you should see this new post appear there, com­plete with sum­mary and images if you’ve pro­vided them, link­ing back to the entry on the source blog.

Con­clu­sion

The basic steps are

  1. iden­tify your source and tar­get blogs.
  2. mod­ify the code in the tar­get blog index tem­plate to include the new Multi­blog block
  3. If you like, cre­ate a new expanded Entry Sum­mary Block; oth­er­wise, 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 sys­tem. Within them you can put posts into divs and apply dif­fer­ent styles, test for other tags, or any­thing else you can cook up.

To make your blog really full-featured, apply the same cod­ing changes to your monthly archive tem­plates 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 '.

September 2010
S M T W T F S
« Aug    
 1234
567891011
12131415161718
19202122232425
2627282930  

New on Flickr

Inquisitive
Small Ferns
Tillman Ravine
Tillman Ravine
Bunny Kiosk
Snow melt, Mahlon Dickerson Reservation
Late afternoon, Dickerson Reservation
Sandy Hook LIghthouse