February 08, 2005

Hierarchical Dropdown List of Category Archives

First, there was the monthly archive dropdown featured on Learning Movable Type. I thought it was a great idea, especially since this blog is starting to get a little long in the tooth (not that long, mind you, but long enough that listing all the archives one by one gets to be a page-design issue because of the length involved). It worked perfectly for my monthly archives, but I wanted to involve the category hierarchy I have put together for my categories in the archive list, and with the template code Elise has on her site, the hierarchy would not be reflected.

Maybe it is a point of pride for the guy that wrote the SubCategories plugin and then integrated it into the Movable Type core. Maybe I figure a flat category listing for my blog would not make any damned sense. Either way, I set out to build a dropdown that incorporated the category hierarchy.

So, with Brad's wonderful PerlScript plugin and a new one of my own creation (Category Depth), here's how I do it.

<form action="" name="pulldowncats">
<select name="pulldowncatsselect" onchange="document.location=pulldowncats.pulldowncatsselect.options[selectedIndex].value">
<option value="">Select Category</option>
<MTSubCategories>
<option value="<MTCategoryArchiveLink>">
<MTPerlScript>
print "&nbsp;&nbsp;"x"<MTCategoryDepth>"."<MTCategoryLabel>";
</MTPerlScript>
</option>
<MTSubCatsRecurse>
</MTSubCategories>
</select>
</form>

Posted by rayners | Comments (5) | TrackBack

June 23, 2003

How Long Has Your Blog Been Up?

With the latest release of my Countdown plugin, I had a neat idea that I figured I'd share with everyone.

So, here's a quick way to display how long your blog has been around, with the Countdown and Entry plugins:

This blog has been up for <MTEntry id="1">
<MTCountup date="[MTEntryDate format='%Y-%m-%d %H:%M:%S']">
<MTCountupIfYears>
<MTCountupYears> years, 
</MTCountupIfYears>
<MTCountupIfWeeks>
<MTCountupWeeks> weeks, 
</MTCountupIfWeeks>
<MTCountupIfDays>
<MTCountupDays> days,
</MTCountupIfDays>
<MTCountupIfMinutes>
<MTCountupMinutes> minutes,
</MTCountupIfMinutes>
<MTCountupIfSeconds>
<MTCountupSeconds> seconds
</MTCountupIfSeconds>
</MTCountup>
</MTEntry>

Obviously you do not have to use the Entry plugin, you just need a way to select the first entry in your blog. I recall seeing a way to do it with the SQL plugin, but I think this way just looks cleaner. Or maybe I am just weird. :)

It could also be trimmed down quite a bit too. You do not have to use all the MTCountupIf tags like I did.

Posted by rayners | Comments (2) | TrackBack

May 30, 2003

How To Prevent Link-Rot in Movable Type or How To Easily Link To An Entry

First, grab copies of the MTMacros and Entry plugins, and install them on your site.

Next, create the following macro:

<MTMacroDefine name="entry_link" ctag="entry_link">
<a href="
<MTEntry id="[MTMacroAttr name='id']"><MTEntryPermalink></MTEntry>">
<MTMacroContent></a>
</MTMacroDefine>

When setup to be included in your entries, this macro will allow you to use the created <entry_link> tag to link to another entry on your site. If you change the structure of your site, the entry only needs to be rebuilt and the links will point to the new archive location.

You can use it in your entries like so:

<entry_link id="125">This</entry_link> is a link to the entry with the id of 125.

Posted by rayners | Comments (4) | TrackBack

Entry List