« Eclipse 3.0 M7 is... | Main | DOD says the end is... »

Introducing Hierarchical Categories in Roller



This weekend, I added support for hierarchical categories to the Roller macros. Hierarchical categories make it easy to partition a weblog and to manage both a main weblog and a number of sub-blogs. For example, I would like to have a link blog where each post is a URL to some interesting place and a comment about that place. I don't want my link-blog links to show up in my main weblog.

I added new category-capable versions of a number of Roller macros, as you can see in the three pairs of methods below. Now, if you want to display only weblog entries one category and it's sub-categories you can use catagory-capable macros to get what you want.

showWeblogEntries($dayTemplate $max):
   Display up to $max number of entries using specified day template.

showWeblogEntriesInCategory($dayTemplate $max $cat):
   Same, except only include entries under $cat.

showRSSLinks():
   Show links to available RSS feeds.

showRSSLinksForCategory($cat):
   Show links to vailable feeds under category $cat.

showWeblogCategoryChooser():
   Show links to all top-level categories.

showWeblogSubcategoryChooser($cat):
   Show links to top-level subcategories under $cat.

But those category-capable macros are not enough to support the main-blog and sub-blogs arrangement that I had in mind. To get that, I added the notion of a main category to Roller. Now you can specify a main category for your weblog, and the showCategoryChooser(), showWeblogEntries(), and showRSSLinks() methods will treat that main category as the root of your weblog.

It is easier to understand this by example, so I'll tell you what I did to this site. Before re-arranging my site, my category tree looked like this:

+  Root <-- MAIN CATEGORY
   + General
   + Java
   + Rolling
   + Blogging
   + Dot-Net
   + Links

My main category was my root category and my top-level categories were Java, Dot-Net, General, Blogging, and Links. I wanted to partition my weblog so that my links category no longer shows up on my main blog and in my main RSS feed. To accomplish this, I rearranged my categories to look like this:

+  Root
   + Main <-- MAIN CATEGORY
      + General
      + Java
      + Rolling
      + Blogging
      + Dot-Net
   + Links

I moved my main-blog categories under a category at path /Main and set that as my new main category. Now, without changing any macros on my weblog pages, my weblog and RSS feed will include only entries from under category. As you can see by hovering over the links above in my category chooser, the links now point to category paths /Main/Java and /Main/Blogging rather than just category names Java and Blogging as they used to. You can also see the same effect in my RSS feeds on the lower right-hand side of the page. The RSS feeds macro now displays only the top-level categories under the main category and my main RSS feed now includes only posts made in the main category and it's subcategories.

To display entries under my Links category, which will be my link-blog, I'll use the new showEntryLinksInCategory("/Links") macro. I'll add that later, probably right under my calendar on the right-hand side of the page.

All this stuff works fine if Roller is configured to use Hibernate, which is the Roller default, but under Castor-JDO, fetching of subcategories does not work. It was important to me, for performance reasons, to be able to fetch all entries under a category and in all subcategories by using a single query. I don't think a recusive approach with queries at every level would be performant. To accomplish the one query, I had to de-normalize the Category table by adding a Category-Assoc table. By issuing a single multi-table query, I can get what I want, but most unfortunately, Castor-JDO does not support multi-table queries. So, long story short, if you use the Castor-JDO backend, you are stuck with a single level hierarchy.

Comments:

Where is the link? so I can download the binary. still 0.9.8.1 since last october

Posted by Frans on February 18, 2004 at 11:36 PM EST #

Soon come!

Posted by Dave Johnson on February 19, 2004 at 07:42 PM EST #

Post a Comment:
  • HTML Syntax: NOT allowed

« Eclipse 3.0 M7 is... | Main | DOD says the end is... »

Welcome

This is just one entry in the weblog Blogging Roller. You may want to visit the main page of the weblog

Related entries

Below are the most recent entries in the category Roller, some may be related to this entry.