Don't Back Down

Posted by Chad Everett on September 18, 2003

Enhancing Category Tags »

I recently stumbled across David Raynes' excellent SubCategories plugin. This piece of software allows you to define existing categories as parents and children of one another.

For instance, I have a Movable Type category. This category has been defined as a parent of my SomeDays and ModCheck categories.

So when you go to my Movable Type category archives, you will see those entries (such as this one) that are entered directly into the category, as well as those entries that belong on the child categories of MT-SomeDays and MT-ModCheck. Meanwhile, MT-SomeDays and MT-ModCheck can exist as their own separate categories too.

The problem that I ran into while doing this is that the most excellent Supplemental Category Tags plugin by Brad Choate didn't recognize these subcategories that I had configured. So over in my recent post bar for the categories, it would list not only parent categories for next/previous navigation, but these children as well. I didn't want that. I wanted to keep the child categories separate. That's why I was doing the whole thing!

So I toyed with it and and tinkered with it and finally figured I'd have to do something about it myself. No sense bothering Brad or David with such a minor issue. So I updated Brad's plugin so that it looks for a subcategory, as defined by David's plugin. The result is that the next/previous options will not display subcategories - only parents. If a category is defined as a child of any other category, then it will not be listed as a next/previous option. If you don't happen to have the SubCategory plugin defined, have no fear - the plugin will still work. Although since you don't have subcategories, you don't really need this version!

As Brad uses the MIT license for the distribution, I think it's safe for me to make it available to you for download, in case you've run into the same issue. If not, well, I'll have to take it down and tell you how I did it so you can make the change yourself!

Related Entries

Comments (2)

I like what you were able to do for next/previous options. I'm looking over your code to see how I can hack it to do something similar.

I want to be able to distinguish between Parent and Subcategories so that I can create a dynamic menu for my site. Imagine MeanDean's redlandbaptist.org site but with a dynamically generated Milonics menu with the top level menu defined by Parent categories and submenus defined by subcategories. So far I'm hung up on displaying Parent categories without displaying any subcategories. arrgh.

something like the following:

foreach MTParentCategory {
print top-level-menu-item
}

foreach MTParentCategory (
print MTentries-and-subcategory
)

foreach MTSubcategory (
print MTentries....

}

Any ideas? You're the closest I've come to a solution with google.

Using the existing structure of the MTSubCategories tag by itself will pull in only parent categories. Not sure if that's what you're looking for, but I'd suspect it's a start. Let me know what else you're trying to accomplish and we can go from there...

Post a comment