My first Movable Type Plugin: MTIfBlogId

Last night I had a little trouble getting to sleep, so I created the MTIfBlogId plugin (right click and choose “save target as” to download). If you’re not aware, there’s only one search template for each Movable Type installation. Inspired by Brad Choate, I decided to create a custom Movable Type plugin to allow us to customize our search pages so that each of my serverneighbors can have their own look and feel.

Here’s a sample usage:

<MTIfBlogId blogid=”5″>

You can see it in action by searching from my blog as there should be three stars at the bottom of the page. You won’t see those stars when searching from any of the other blogs on knitwitology.net. If I have time tonight, I’ll fool around with making some more meaningful changes to the search template.

The plugin works by comparing the blogid attribute’s value as set in the tag with the IncludeBlogs query string parameter passed to the mt-search.cgi. In hindsight, I probably should have just created a plugin that would work for any querystring parameter, but hey I have to sleep some time.

My first experience with extending MT was great. I’m a total PERL newbie, but I was able to add the necessary functionality without any trouble. It took only ten or so lines of code, and I didn’t have to fiddle with configuration files or registering DLLs. Sweet!

Special thanks to Stephen Riha for his online copy of the MT PERL API which was invaluable to me as someone getting started w/ the API.