Learning Movable Type: Category Customizations

One area where plugins have greatly enhanced MT functionality is in categories. Here's a list of some of the things you can do:

How to exclude entries of certain categories from lists of entries.

Say you want to list out your 20 most recent entries in your sidebar, except for the entries in the Special Announcements category. This is easy enough to do with the Exclude Categories plugin. The code would look like this:

<MTEntriesExCat category="Special Announcements" lastn="20">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />

How to list entries only from certain categories.

This trick doesn't require a plugin at all. Just add the category attribute after the MTEntries tag like so:

<MTEntries category="Special Announcements" lastn="20">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />


<MTEntries category="Special Announcements AND Music" lastn="20">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />

How to show Previous and Next Entry within a category.

On your individual entry archive pages MT by default lists the previous and next entries from your blog. Suppose you only want to show the previous and next entries within that entry's primary category, like I've done with my photo album example? You'll need to install Phil Ringnalda's PreviousNextInCategory plugin. The code will look like this:

<a href="<$MTEntryPermalink$>">&laquo; <$MTEntryTitle$></a> |
<a href="<$MTEntryPermalink archive_type="Category"$>"><$MTEntryCategory$></a>
| <a href="<$MTEntryPermalink$>"><$MTEntryTitle$> &raquo;</a>

How to exclude a category from a list of categories.

The Filter Categories plugin helps you to include or exclude certain categories from a list of categories.

How to create a link on your Individual Entry to the Category page of the primary category of that entry.

This shouldn't be difficult, but it sure had me stumped trying to figure out how to do it. Thanks to Support Forum contributor Maddy for the clue.

<a href="<MTEntryLink archive_type="Category">"><MTEntryCategory></a>

How to have entries from different categories display different styles.

Say you want the entries on your main blog page to show a different background color depending on what primary category they are in? To do this first create additional classes in your stylesheet with the styling for those categories. For example, if you wanted your entries in your "news" category to be in a green box, add this element to your stylsheet:

.news {
padding: 10px 10px 10px 10px;
background-color: #effbdb;
border: solid 1px #7c9e40;

Then in your Main Index template, add the div class
<div class="<$MTEntryCategory$>">
just after the MTEntries tag. Close the tag by adding a </div> before the closing MTEntries tag. As long as your stylesheet class name and your category name is the same, you should be able add unique styles to your different categories. Many thanks to LMT reader Mariann for this tip!

Movable Type Manual section on category tags
MT Forums thread on how to add category specific images to your category pages
Category Icons - Arvind from Movalog shows how to use specific icons to represent categories.
Per-Category Individual Entry Archive templates - how to have different Individual Entry templates depending on the category, from Shelley of The Girlie Matters.
Sorting categories non-alphabetically - a tutorial using Regex from Movable Type Weblog.

Posted by Elise Bauer on June 10, 2004 04:12 PM to Learning Movable Type http://learningmovabletype.com/