O'Reilly logo

Mastering Joomla! 1.5 Extension and Framework Development by Chuck Lanham, James Kennard

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Trees

Trees are used to model hierarchical data. Joomla! provides us with the JTree and JNode classes; we can use these to build tree data structures. Before we start using these classes we must import the relevant library:

jimport('joomla.base.tree'); 

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required