Saturday, February 19, 2011

Tree library for PHP using left & right ids

I'm looking for a library in PHP that can create a tree structure from a database (or array of values) with left and right ids. For the result when getting values I am only looking for an array so I can create any type of view. For adding and removing, it would be nice if the library did it all. Even if the library is within another library, I don't mind as I'll probably pull it out and integrate it with my own libraries.

Anyone know of anything?

I'm using PHP & MySQL, so it'd be helpful if it used atleast PHP. If it's a different database I can probably convert it, although maybe the same with PHP if it doesn't use too much language specific functionality.

From stackoverflow
  • This approach is called "nested sets"

    http://stackoverflow.com/questions/272010/searching-for-the-best-php-nested-sets-class-pear-class-excluded#272248

    basically there is the NSTree library which doesn't seem to be maintained and there is a PEAR library. Probably there are others but that's just a summary of the other post.

  • ezComponents Tree library has different backends (tie-ins), that you can choose between. The documentation is pretty good as well.

  • I am in the midst of a project that uses tree structures for navigation and also selection of (what to) update. I must admit that (being self-taught) I wasn't that familiar with the left-right values approach and so opted for what I have just discovered via a very helpful article to be called The Adjacency List Model.

    Having thought about it, and now being somewhat more familiar, I still think I'd do the same. With TALM, coding PHP views & updates are easy as you're primarily concerned with the parent relationship of a node.

    Then for display you have jQuery Treeview, which I can't recommend highly enough, and for selections there's jquery-checktree which I'm still in the process of incorporating and so can't vouch for, but looks good.

0 comments:

Post a Comment