arrow-left arrow-right brightness-2 chevron-left chevron-right facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
How to create a linkblog in Movable Type
3 min read

How to create a linkblog in Movable Type

First off, let me apologize for using the word ‘linkblog’ — I’m not a fan of it myself and am only using it because it seems that that is what this sort of thing is being called (and if you got here from Google then I chose the right word   :P).

I’m going to start by going over two solutions that I didn’t choose to implement, but that might be of some use to you, and then I’ll explain the method I came up with, which is easy to setup and use.

The Easiest Method

The first thing that came to mind when I decided that I wanted to do this was to simply create a category in my current Movable Type weblog. To post a new link you would just create a new post in your current weblog and put it into the new category. The code to list the latest links would be very similar to the code you already use to display your weblog entries, except that you’d limit the output to link entries through the use of category tags.

This is all well and good and I’d imagine that most people would be fine with this solution, but I had a couple of problems with it. The biggest problem for me was that these tiny, one-line posts would be interlaced with the regular posts (on my end) — I wanted to keep the linkblog completely separate from my normal posts. Just my preference. The other thing that bothered me was the Post Status option. For my regular entries I like the default Post Status set to Draft, but for the linkblog I wanted it set to Publish — there is no way to set this variable based on the category of the post. Again, this might not bother you.

The Worst Method

The first thing I did after deciding that I was going to create a linkblog was to look for a Movable Type plugin that already did what I looked to do. After being unable to find one, I thought to create another weblog inside my MT installation and then just reference the second weblog from my first (main) weblog. This is not possible in MT! What the hell? Naturally, I immediately went looking for a plugin that would allow me to call other weblogs from my main one. I ran across David Rayne’s MTOtherBlog plugin. A good idea to be sure, but for it to work, one must rebuild their entire weblog. For example, you’d place the MTOtherBlog call in a template where you wanted information from another weblog to be inserted. Then, you’d add a link to your new linkblog. Now, while the change has been made in your linkblog, it won’t show up on your main weblog until you rebuild the template where the MTOtherBlog call resides — you have to manually rebuild all the pages that reference the linkblog (in my case, every page on my site) each time you add a new link!

Enter pingToRebuild.cgi, which automatically rebuilds a Movable Type weblog (i.e., you’d setup your linkblog to run pingToRebuild each time you add a link). While this obviates the annoyance of constant manual rebuilding, the fact remains that you’re still left to rebuild each and every time you add a link. I find this unacceptable. You might not.

My Method

This method lets you keep the links in a separate weblog and doesn’t require you to rebuild each time you add a link. Keep in mind that the following is my specific setup; there are a lot of things you can play around with and add depending on your needs. The basic idea is that each time you add a new link to the linkblog, a text file is written with the new link and loaded into any page you wish through PHP. It’s very simple.

The first thing I did was create another weblog within my current installation of Movable Type. I decided that the link’s title would be set by the MTEntryTitle tag and the URI set by the MTEntryBody tag. You could obviously use any of the other variables as you see fit (e.g., you could add a brief description of each link through the MTEntryExcerpt tag, etc). After realizing which tags would be used and for what purpose, I created a new template and named its Output File linked-list.txt. The entire template is shown below:

<MTEntries lastn=15>
<a href=<$MTEntryBody$>><$MTEntryTitle$></a>

That’s it. The new link is wrapped in markup and linked-list.txt is written. As explained above, the title of the post is the title of the link, and the body of the post is the URI itself.

Finally, to pull this file into another template (e.g., your main weblog template), you simply need to add one line of PHP wherever you want the file’s contents to be inserted.

<?php include('absolute/path/to/your/file'); ?>

To make the posting of links faster, I took the obvious step of linking a bookmark in my browser to the New Entry page of the linkblog. After I read an article that I want to add to the linkblog, I copy the URI, hit the bookmark button, put whatever title I want into the title field, paste the link into the body field, and press Publish. Done.

You've successfully subscribed to Justin Blanton.
Success! Your account is fully activated, you now have access to all content.