List Your Subcategories in Order

If you use subcategories in Movable Type, you know that you need to think of them in alphabetical order. Otherwise when you add them, they won’t be in order. How do you get them to look right?

First, export your category table using a utility like phpMyAdmin. Then, rearrange the INSERT statements in a text editor, so that they appear in the order you want them to show up (that is, alphabetically). Actually, you can arrange them in whatever order you like. I like alphabetically.

Next, empty the table. Yes, that’s right, empty it completely. Just make sure you have that file before you do so or you just lost all your categories.

Finally, import those INSERT statements. That’s it.

This works because the current version of Movable Type (3.2) lists categories in alphabetical order, but it lists sub-categories in the order that they exist in the table. I can only assume that this will be fixed in future versions of the software, but I just don’t know.

So by taking the categories out, re-ordering them, and putting them back in, you not only get the categories in the order you want, you don’t mess up your existing category mappings (actually called placements in Movable Type).

You might think that you could accomplish the same thing by changing the category numbers, and moving the entries to the appropriate categories, but you would still have to rearrange the category table or all your work would be for naught.

Update: You don’t need to do this any longer (after version 3.3). All categories – even subcategories – are now sorted correctly. Yay!


Posted

in

Comments

One response to “List Your Subcategories in Order”

  1. Joerg Petermann Avatar

    I read your article with interest searching for an idea to sort subcategories with a plugin in a numeric way.
    I think it would be a good way to write the sort_id in the category description field.

    But I’m not a good perl coder to write such a plugin for myself. Can you give me a tip to come to results?

    Thanks for feedback!