Tree Editor 

A collapsible heirarchical tree component.

Built using PHP, DHTML, JavaScript with persistence handled by hidden form fields.

Features

The main features that distinguish this component are:

  • The tree's nodes can contain arbitrary HTML - and can dynamically resize themselves horizontally and vertically;

  • Persistence of the state of the tree when users leave the page and return to it again is handled using hidden form fields - and does not depend on cookies;

  • Controls are available to collapse and expand multiple nodes in the tree at once;

  • Nodes of the tree are sensitive to the mouse pointer - giving the user immediate feedback about which areas are active.

Demonstrations

Simple tree

Collapse all tree nodesExpand all tree nodes
Expand this node
Collapse
Expand this node
The 1.1 node;
Expand this node
Collapse
Expand this node
The 1.1 node;

A more complex tree - with a nested sub-tree

Collapse all tree nodesExpand as far as level 2Expand as far as level 3Expand all tree nodes
The 1.1 node;
The 1.2 node;
Expand this node
Collapse
Expand this node
The first directory
Expand this node
Collapse
Expand this node
The second directory
Expand this node
Collapse
Expand this node
The third directory
The 3.3 node;
Expand this node
Collapse
Expand this node
The fourth directory
Expand this node
Collapse
Expand this node
The fifth directory
Arbitrary HTML can be placed into each section - including graphics, long lines, tall lines, and text that wraps across multiple lines;
Tables can also be used;
The 3.4 node;
A nested tree:
Collapse all tree nodesExpand all tree nodes
Expand this node
Collapse
Expand this node
The 1 directory;
Expand this node
Collapse
Expand this node
The 2 directory;
Expand this node
Collapse
Expand this node
The 2 directory;

Sites using the tree component

Supported browsers

The tree has been tested with Internet Explorer, Mozilla, Firefox and Opera.

If there is no browser support for DHTML, JavaScript - or whatever - the usual behaviour will be to show the tree with all the nodes expanded.

This is normally a pretty safe fall-back position - and ensures all the content is still accessible.

Not all browsers support persistence via hidden form fields.

Mozilla/Firefox do not do it yet - for example. If there is no support for persistent form fields, then the tree's state won't persist either.

Rendering trees from a database

Code for rendering trees from an SQL database is available - but it comes with the tree editor - and is not in the smaller download containing just the tree component.

Rendering trees from an XML file

This code hasn't been written yet.

Source code

A zip file containing all the relevant files is available here.

License

This program and its source code have been placed into the public domain by its author.


Tim Tyler | Contact | http://treeeditor.com/