Trees are used to model hierarchical data. Joomla! provides us with the
JNode classes; we can use these to build tree data structures. Before we start using these classes we must import the relevant library:
The first thing we do when building a new tree is to create a new
JTree object. Although a
JTree object is not technically required in order to create a tree it ensures we can easily access the root of the tree. There are no parameters that we need to pass when creating a new tree:
$tree = new JTree();
When a new tree is created a new root
JNode object is automatically created. The root node is the node to which all other nodes in the tree belong.
Once we have created a tree we must add child nodes ...