As I posted previously, I have been working on the back end of Massassi since I came back. One of the things I've been struggling with was a "tree" structure. Many things across Massassi are stored in trees or should be stored in trees. Files, especially, but also pages on our site (all of our "static" content will be stored in a database from now on).
Anyway, most people use this id/parent_id thing to store a tree structure in a database. It requires a recursive function and a lot of queries to retrieve said tree if it's stored that way. I have been reading a lot about a different way to store tree data in a database called the "nested set" model. I have implemented a nested set solution, and I can now get a tree in one SQL query as well as the path to any node. Virtually all data retrievals take one query (while inserts take 3 queries - but inserts don't happen often so that's okay).
On top of that, I have created a PHP class that takes a tree structure and renders it in HTML and JavaScript. The JavaScript is so you can control the tree structure via plus/minus links similar to say Windows Explorer.
Further, since an arbitrary number of data types can be stored in a tree, and thus, rendered by my PHP/JS tree class, I added support for dynamic typing of tree data.
This is probably all very confusing if you're not a programmer, but this screenshot should make it clear. Clicking a "closed" folder makes it open. Different data types can have different icons (see the file icons there - index.php/old.php), and any number of "widgets" can be added to all nodes, parent nodes only, child nodes only, or on a per-type basis (as is the case with the edit/delete icons). Widgets can be any arbitrary HTML, but will most likely usually be check boxes, radio buttons, links, or images.
The JS works on IE/Opera/Mozilla (and probably KHTML/Safari although I haven't tested).
This will basically make adding/updating content on Massassi a -lot- easier for the staff. But I've been working on the tree logic for about a week now so I just had to show it off.
First shot is the tree in action, second shot is editing a page (what you get by clicking on the edit/pencil icon in the page tree).
http://www.massassi.net/etc/m2_admin_1.png
http://www.massassi.net/etc/m2_admin_2.png
[edit - they're too wide, switched to links]
[This message has been edited by Brian (edited December 24, 2003).]
Anyway, most people use this id/parent_id thing to store a tree structure in a database. It requires a recursive function and a lot of queries to retrieve said tree if it's stored that way. I have been reading a lot about a different way to store tree data in a database called the "nested set" model. I have implemented a nested set solution, and I can now get a tree in one SQL query as well as the path to any node. Virtually all data retrievals take one query (while inserts take 3 queries - but inserts don't happen often so that's okay).
On top of that, I have created a PHP class that takes a tree structure and renders it in HTML and JavaScript. The JavaScript is so you can control the tree structure via plus/minus links similar to say Windows Explorer.
Further, since an arbitrary number of data types can be stored in a tree, and thus, rendered by my PHP/JS tree class, I added support for dynamic typing of tree data.
This is probably all very confusing if you're not a programmer, but this screenshot should make it clear. Clicking a "closed" folder makes it open. Different data types can have different icons (see the file icons there - index.php/old.php), and any number of "widgets" can be added to all nodes, parent nodes only, child nodes only, or on a per-type basis (as is the case with the edit/delete icons). Widgets can be any arbitrary HTML, but will most likely usually be check boxes, radio buttons, links, or images.
The JS works on IE/Opera/Mozilla (and probably KHTML/Safari although I haven't tested).
This will basically make adding/updating content on Massassi a -lot- easier for the staff. But I've been working on the tree logic for about a week now so I just had to show it off.
First shot is the tree in action, second shot is editing a page (what you get by clicking on the edit/pencil icon in the page tree).
http://www.massassi.net/etc/m2_admin_1.png
http://www.massassi.net/etc/m2_admin_2.png
[edit - they're too wide, switched to links]
[This message has been edited by Brian (edited December 24, 2003).]