For a current project I’m trying to get a better idea of what’s available in PEAR. PEAR has come on a long way since I last explored it in any seriousness.

Today’s undertaking was an exploration of DB_NestedSet. Up till now I’d had a simple parent-child category map but I needed to make it a little more flexible, reduce database overheads and simplify maintenance. Using NestedSet looks like a solution to all of those, though some refactoring may be in order. The key thing that’s missing is good documentation and it did take a fair bit of googling to get things going as I’d like.

For those new to working with nested tree structures, this article at sitepoint does a decent job of introducing them and this one is the best tutorial on DB_NestedSet google could produce, but note that it’s designed for recent (still beta) versions of DB_NestedSet.

What neither of those links describe is how to perform a number of other useful functions, such as moving and deleting nodes, or getting a view of a subset of the tree.

The next step is going to be to write a new wrapper around the results produced. The example uses HTML_Menu which is throwing me table-based HTML. Should be easy enough to write a plugin for smarty that parses through the output of NestedSet (pre-HTML_Menu) with a recursive function and produces some nice XHTML lists.

Tags: , , , ,

Comments are closed.