Leo's MovableType Tips

by Leo A. Notenboom

by Ask Leo!

Get creative with Templates

There's nothing that says MovableType templates can't be added to create other types of files.

The challenge I had was this: I want to be able to have a list of all my category archive pages on some of the other pages that are not built by MovableType.

The solution? Create an index template that contains that list - and only that list - and have it produce an include file that I can use anywhere I like.

Here is the template, in its entirety:

<p><b><a href="/archives.html">The Full Archive</a></b></p>
<MTSubCategories>
<MTSubCatIsFirst></MTSubCatIsFirst>
<p style="font-weight: normal; margin-top: 0; margin-bottom: 0;">&bull; <a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$></a></p>
<MTSubCatIsLast></MTSubCatIsLast>
</MTSubCategories>

We'll create that as a new index template, called "catlist.inc":

Index Listing with Catlist

Now, when we cause a rebuild of the indexes, catlist.inc is updated. Here's what the beginning of that file looks like as I write this:

<p><b><a href="/archives.html">The Full Archive</a></b></p>
<p style="font-weight: normal; margin-top: 0; margin-bottom: 0;">&bull; <a href="http://ask-leo.com/administration.html">Administration</a></p>
<p style="font-weight: normal; margin-top: 0; margin-bottom: 0;">&bull; <a href="http://ask-leo.com/email.html">EMail</a></p>
<p style="font-weight: normal; margin-top: 0; margin-bottom: 0;">&bull; <a href="http://ask-leo.com/general_computing.html">General Computing</a></p>
...

That's a fine file that can be included elsewhere. For example, on my actual "Ask a Question" page, http://ask-leo.com/askleo.html, which is a manually created page, below the entry form for a question you'll see a list of the categories available for browsing:

Archive List in Ask Leo! page

That's the result of the following include:

<!--#include VIRTUAL="catlist.inc" -->

If that looks very similar to the category list that's presented on the Ask Leo! homepage, it should ... the home page uses the exact same include to present the category list.