Nintendo Wii forums Forum for writers phpBB mods Essays on copyright Dating advice Narnia forums

Movable Type Plugin: MTAgain

What is MTAgain?  Why do we need it?

MTAgain provides looping to Movable Type.  For example, say you want to list not only the previous blog entry, but the one before that and the one before that.  MTAgain lets you do that.  Essentially, what it can do is put a tag like MTEntryPrevious inside itself, and it can do that thousands of times if you're crazy enough to try it.

The MTAgain plugin for Movable Type is not my own creation.  Someone named Lummox JR wrote it years ago, and then disappeared.  In fact, I couldn't find his original plugin anywhere – even the Web Archive didn't have copies of his long-gone Web site!

What I did find was an article that mentioned the plugin and, when readers complained that the plugin didn't exist anymore, offered the code.  However, they never offered an instruction manual.  With the author's site gone and the manual missing, I had to do some sleuthing.  In particular, I couldn't really guess what the "any" feature did.  But I found an old forum post, learned the code, revised and expanded it, and now I offer it to you with a useful new feature.

If you just want to just skip the tutorial here, you can go ahead and download MTAgain 1.2 for Movable Type now.  But if you want a quick overview of what this thing can do, read on.

The MTAgain plugin has been updated for Movable Type 3.x.  It probably runs in 4.x but I wouldn't know.  I revised it so that when you install it, it appears on the plugin page.  And I gave it a new tag.  Here is a review of what each tag offers:

<MTAgain limit="100">

This a container tag that you wrap around the code you want to repeat.  The limit attribute is optional, but I suggest you include it.  The old MTAgain plugin had a hard-coded limit of 50, so it was impossible to lock up a server with endless looping.  That's great for safety, but it also makes it impossible to loop through thousands of blog entries.  Since I wanted to do exactly that, this version of MTAgain has a limit of 1000.  If you don't need it looping that deeply, you should set a limit.


This a token that you place in the spot where you want the code to repeat.  This needs to be inside the MTAgain tags.  This is a difficult concept for some.  You are putting the code inside of itself.  But it isn't that hard.  Consider this code:

<MTAgain limit="3">

You've put the MTEntryPrevious tags inside the MTAgain tags, so the MTEntryPrevious tags are going to repeat. Where will they repeat? Where the MTAgainHere tag is – inside the MTEntryPrevious tag. This means it shows the name of the previous entry, then shows the name of the entry previous to that and so on. See?

<MTAgainStop any="1">

This is a container tag that you wrap around the code you want to appear when the loop ends.  The "any" attribute is optional.  Since there are two ways to end the loop, the any attribute determines which ending it responds to.  The first way a loop can end is that it peters out, never hitting your hard limit.  For example, if you limit the loop to running 5 times but there are only 3 items to loop through, you never hit the hard limit of 5.  In such a case, <MTAgainStop any="1"> will display your "it petered out" markup.  However, if you need to display something when the hard limit IS reached, then you want a plain <MTAgainStop>.  That will not run if it peters out, but it will run if the hard limit is reached and the loop is forced to stop.


This a new token tag that I've added.  It's not a wrapper.  You just place it somewhere and it kills the loop, even if the limit hasn't been reached.  Used with normal MT tags it almost doesn't make sense – wherever you put it, it'll kill the looping immediately, so what's the point?  Well, if you're using conditional tags, it gets much more interesting.  Consider what happens when you couple this with the <MTIfEqual> tag from the Compare plugin:

<MTIfEqual a="[MTTagName]" b="rocknroll">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><MTAgainBreak>

What does that do?  To start, it keeps going backwards through previous entries – that's what MTAgain & MTAgainHere gets you.  But notice the MTIfEqual tag – it's watching for a specific tagged entry.  When it finds it, it prints out a link, followed by MTAgainBreak, which ends the loop.  Thus, you can have a link to the "previous entry tagged as rocknroll."  I'm sure you'll think up cooler applications.

Ready?  Download MTAgain 1.2 for Movable Type 3.x.  Have fun!


« Movable Type plugin: Gravatars | Main | How to do photos for a MemoryFrame (model MF-8000) »

Nav by tag: movable_type
« Movable Type plugin: Gravatars | Main
Bookmark It! Technorati Netvouz DZone ThisNext Wists blinkbits BlinkList blogmarks blogtercimlap Blue Dot Bumpzee co.mments connotea DotNetKicks Fark feedmelinks Fleck Furl Gwar Haohao Hemidemi IndiaGram IndianPad Internetmedia LinkaGoGo Linkter Ma.gnolia MyShare Netscape NewsVine PlugIM PopCurrent ppnow RawSugar Reddit Shadows Simpy Slashdot Smarking Spurl Webride YahooMyWeb

TrackBack URL for this entry:

Comments (3)
Su writes:

Nice! I've been meaning to give Lummox's old plugins a home for a long time now and never get around to it. I tracked him down a while back, and for what it's worth he's said to essentially consider the code out in the public domain.

I've got a copy of the original distribution, with his original docs, that I can send you if you want to look them over and make check if your reading of the code is correct or missing anything. I haven't compared the two myself yet.

Also, have you submitted this to the plugin directory?

Tony writes:


Yes, please, I'll take a copy. I'll email you. Thanks.

I haven't put this in the plugin directory, since the original is already there, and since I built to the 3.34 version of MT. Do they even want plugins for 3.x? I'll take a look.


quest bars writes:

Ahaa, its fastidious dialogue about this post here at this
weblog, I have read all that, so at this time me also commenting at this place.

Post a comment

Verification (needed to reduce spam):