Brian's Blog Homepage
joomla nested categories
joomla nested categories

If you have been following the development of Joomla 1.6 you will have noticed that one of the new features is nested categories.

This means that you are no longer limited to the Section-Category-Article paradigm but can have as many levels of categories as you wish.

I've explained before how the current system works and how to understand the limitations by comparing it to a filing cabinet.

Personally I have never had an issue keeping my back-end filing system and my front-end navigation system separate but I know that many many people do. It's been this way since the early Mambo days so I guess I have grown up with the structure and it's not a problem for me.

So why has it taken so long to change.

At a basic level it would have been easy to change. The current system uses an ID for a section and each category has both its own ID and a SECTIONID to indicate the parent (or section it belonged in).

Hierarchical system

Sections, Categories, sub-categories etc are an hierarchical system and relational databases just aren't very good at handling them.

If you queried to find all the categories

SELECT * FROM category ORDER BY category_id;

You would get a list of the categories but no hierarchical tree.

You could start building more and more complex adjacency queries to build the correct tree but that just will not scale well for larger sites and there are many issues to handle relating to deletes and inserts. All of which are a performance hit and a potential area of disastrous mistakes where deleting a category leaves everything below it orphaned etc etc.

So how is it done in Joomla 1.6

To put it simply Joomla 1.6 had abandoned the hierarchical system for a nested set model.

At this point I really should be drawing diagrams to explain how nested sets work, providing samples to show the simplicity (and poetry) of the queries but I'm lazy. Someone has already done it and at this point I hand you over to Mike Hillyer who does a far better job at explaining this than I ever could.

Continue the explanation at I promise you that you will be able to understand it - money back if you can't.



J o o m l a !

Brian Teeman

Brian Teeman

Who is Brian?

As a co-founder of Joomla! and OpenSourceMatters Inc I've never been known to be lacking an opinion or being too afraid to express it.

Despite what some people might think I'm a shy and modest man who doesn't like to blow his own trumpet or boast about achievements.

Where is Brian?