Setting up category indexes in Movable Type

| 1 Comment

After migrating my weblog from Radio Userland to Movable Type, I searched for a way to create category archive pages as a list of post titles which link to the individual archives, displaying a header for each month/year. (I will refer to these pages as "post index" pages.)

Creating such a post index is not as easy as it would appear, even for the main weblog. In order to display month/year headings, monthly archives must be enabled, even if you don't want them or use them for any other purpose. A separate index template must be created for each category that will have a post index page, because date-based archive template tags (necessary for the monthly headers) cannot be used with category archive template tags. Girlie, a moderator on MT's support forums, posted instructions on how to do this, as well as the template code needed in each category's post index template.

I followed Girlie's instructions, not having any other alternative at the time. I was not satisfied with this answer though, because 1) I had to create and maintain one additional index template for each category (6 so far), and 2) I had to have monthly archives enabled on my weblog, even though I was not using monthly archives for anything else.

I thought it might be possible to use a couple of MT plugins to store a post's month and year in a variable, then check the month and year of subsequent posts to see if it has changed and display a new month / year header when it does. I started looking for plugins that might allow me to do this and stumbled across the EntryList plugin. It is not readily apparent from the plugin's documentation, but one of the plugin's features is exactly the type of sorting, grouping, and headers that I was looking for.

After installing the EntryList plugin, I created a new archive template called "Category Index". Within this template, I used the following template code to create the index of posts with a header for each month / year:

      <MTEntryListSection name="month">
        <$MTEntryDate format="%Y%m"$>
        <MTEntryListHeader name="month">
          <b><$MTEntryDate format="%B %Y"$></b><br />
        <li class="indexListItem">
        <span style="display:block; float:right; padding-left: 20px;"><$MTEntryDate format="%b %d"$></span>
        <a href="<$MTEntryLink archive_type="Individual"$>"><$MTEntryTitle$></a>
        <MTEntryListFooter name="month">

The above code will generate a separate post index with month/year headers for each category. Each post is bulleted, and the date of each post will be displayed to the right of the post.

I then added the "Category Index" template to the Category Archives on the Weblog Config | Archiving preferences page, and set the archive file template to "postIndex_<$MTArchiveCategory dirify="1"$>.html" so I did not overwrite my regular category archive pages.

I was then able to delete the 6 custom index templates I had created before to do this, plus disable the monthly archives that I no longer needed. A much better solution, one that I am very satisfied with.

1 Comment

This is amazing. Thank you thank you thank you.