Easy Blogroll for MT in one template

More links to your blog means more visitors. Bloggers check to see who is linking to them; if they like the blog that links to them, they may link to it. A blogroll is a list of links to other bloggers. (You need not take my word, it says so over at Learning Movable Type.)

That is the basic logic behind a blogroll. A nice young fellow Arvind Satyanarayan has written a full featured commercial plug-in for Movable Type which helps users manage blogrolls, and has nice features, such tracking the last update to the blogs on your blogroll. If you need features, check it out.

But, maybe you don’t want to run a program that requires PHP. Maybe you don’t feel like paying for a plug-in. Maybe you won’t want to give your email address just to download the plug-in to evaluate it.

Maybe, like me, you just appreciate the beauty of a simple hack.

The other day, I was looking at Feeds.App Lite, by Tim Appnel which is bundled with MT 3.3. There is also a commercial big brother to this plug-in, called not surprisingly: Feeds.App. It occurred to me that Tim’s plug-in generates a list of links too. And all it needs to do this is a XML file formatted in the correct way! Fortunately for us, Movable Type is a publishing platform that doesn’t really care what it publishes, and is fully capable of writing XML. (It even includes some XML templates so I didn’t have to look at the standard, I just hacked what I found. Maybe I should have checked the standard.)

Objects in the mirror appear closer: Use at your own risk

Here are the steps I used:

  1. Make a new blog, name it something like “Blogroll”.
    • I carefully put mine in the same path and URL as my main blog. DO NOT REBUILD YET.
    • Go to templates and remove all the index and archive templates except for the Atom template.
    • Edit and change the name of the output file of the Atom index template. I suggest you name the output file blogroll.xml
  2. Put this code in the Atom template in place of what is there now.
    <$MTHTTPContentType type="application/atom+xml"$>
    <?xml version="1.0" encoding="<$MTPublishCharset$>"?>
    <feed xmlns="http://www.w3.org/2005/Atom">
    <title><$MTBlogName remove_html="1" encode_xml="1"$></title>
    <id>tag:<$MTBlogHost exclude_port="1" encode_xml="1"$>,<$MTDate format="%Y"$>:<$MTBlogRelativeURL encode_xml="1"$>/<$MTBlogID$></id>
    <updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
    <MTEntries lastn="1000" sort_by="title" sort_order="ascend">
    <entry>
    <title><$MTEntryTitle remove_html="1" encode_xml="1"$></title>
    <link rel="alternate" type="text/html" href="<$MTEntryBody encode_xml="1" convert_breaks="0"$>" />
    <id><$MTEntryAtomID$></id>
    <published><$MTEntryDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></published>
    <updated><$MTEntryModifiedDate utc="1" format="%Y-%m-%dT%H:%M:%SZ"$></updated>
    <author></author>
    <content></content>
    </entry>
    </MTEntries>
    </feed>
    
  3. Put the following code into your sidebar wherever you want the blogroll to appear; the generated xhtml list has no class or id attributes, so you should form all your CSS selectors using the list’s parent entities on your template.
    <$MTFeedInclude uri="http://www.yoursitehere.com/blogroll.xml" $>
That is the whole setup.

To create an entry in your blogroll, you create an entry in the new blog you named “Blogroll”. The title of the entry holds the name and the Entry Body contains a fully qualified URL such as : http://www.advisorbits.com

You can edit your blogroll blog using the skills you already have with Movable Type. When you rebuild that blog it only rebuilds one file, the blogroll.xml file. When you rebuild your main blog it will read the latest copy of blogroll.xml and include it in your sidebar, thanks to Feeds.App Lite.

One Response

  1. Eric Sundwall
    Eric Sundwall June 20, 2007 at 6:23 pm | | Reply

    This works great if you trash this line – updated $MTEntryModifiedDate utc=”1″ format=”%Y-%m-%dT%H:%M:%SZ”$ just before the – MTEntries lastn=”1000″ sort_by=”title” sort_order=”ascend”>
    You also have to be careful about the default path. I created a separate directory called ‘blogroll’, apparently it needs to hangout in the root area . . . Thanks AdvisorBits

Leave a Reply