Per-Category Templates 1.0

June 13, 2003 - updated February 8, 2006

MovableType allows you to specify a variety of templates for indices, individual and time-based archives and for category archives. Curiously, you can’t specify a template per category—an often requested feature.

However, using template modules and a cleverly designed archive template, you can easily create individual category templates.

The basic idea

The individual category templates will be stored as template modules. The actual category template is going to contain code that is going to MTInclude the appropriate category template based on the archive’s category.

Let’s assume you have four categories called “Cats”, “Dogs”, “Roses”, and “Lilies” and you want each to have a different template. You would create each template as a template module and save it with a corresponding name: “Category Cats”, “Category Dogs”, “Category Roses” and “Category Lilies”.

All that is left for the actual category template is to pick the right template module to include.

Picking a Category using Supplemental Category Tags plugin

The MTSuplemental Category Tags plugin can be used to output content if the current category (in the context of a category archive template) matches a given name or pattern. Using this plugin, your category template might look like so:

<MTIfCategory name="Dogs"><MTInclude module="Category Dogs"></MTIfCategory>
<MTIfCategory name="Cats"><MTInclude module="Category Cats"></MTIfCategory>
<MTIfCategory name="Roses"><MTInclude module="Category Roses"></MTIfCategory>
<MTIfCategory name="Lillies"><MTInclude module="Category Lillies"></MTIfCategory>

Selecting a Category using MTIncludePlus plugin

You can make your category template even simpler by using the MTIncludePlus and MTCategoryOfArchive plugins. With these plugins, your category template becomes as simple as this:

<MTIncludeModule><MTCategoryOfArchive>Category <MTCategoryLabel></MTCategoryOfArchive></MTIncludeModule>