June 27, 2005
Movable Type and Category Orders
So it turns out that the default order in Movable Type for categories is alphabetical, which if fine for some things, but not so hot for others. I spent the last few hours changing this so I could better organize my categories according to my priorities
The change is not that hard and basically involves installing Brad Choate's regular expression plugin and editing a few lines in your templates. Here is the process expanded a bit from the original reference that I found with google.
- Download and install Brad Choate's regular expression plugin for Movable Type. The readme.txt has the install details with basic usage. The most chalenging aspect was finding where Movable Type is installed on our systems.
- Link the main index template to a local file that you can edit. Note: order is important on this. Link the file first, then copy in your new template or make changes.
- Rename all of your categories with a fixed prefix that when ordered alphabetically will result in the order you want for the categories. For example, a category prefixed with CatA: will come before a category prefixed with CatB:. You get the point I hope.
- Edit your local template file (for me is is the main index template) to use regular expressions to remove the prefix from the categories in the generated HTML labels. I do not have the patience to HTML'lize the code, so here is a plain text file with it.
- <$MTEntryTitle$> [<$MTEntryCommentCount$> comments; posted <$MTEntryDate format="%e %b"$>]
- <$MTEntryTitle$> [<$MTEntryCommentCount$>; <$MTEntryDate format="%e %b"$>]
- All <$MTCategoryLabel regex="catrm"$$> entries
Posted by egm at 01:44 PM | Comments (0)