previousSimple example (Previous) (Next) Pagernext

View this page in Last updated: Tue, 02 Jun 2009
English | Brazilian Portuguese | Chinese | Dutch | French | German | Hungarian | Japanese | Polish | Russian | Spanish | Turkish

Tree-construction methods

Actually, you have three different methods to build the tree:

By hand

This is the 'hard' way, like the example above. You have to set each node by hand.

Importing XML

You can import a formatted XML file into the tree structure. It supports string of XML_Tree object :)

XML Format

<treemenu>
  <node text="First node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
  <node text="Second node" icon="folder.gif" expandedIcon="folder-expanded.gif">
    <node text="Sub node" icon="folder.gif" expandedIcon="folder-expanded.gif" />
  </node>
  <node text="Third node" icon="folder.gif" expandedIcon="folder-expanded.gif">
</treemenu>

Example with a string (not tested)

<?php
require_once 'HTML/TreeMenu.php';

// Load the XML file
$xml file_get_contents('tree.xml');

$menu = new HTML_TreeMenu();
$menu->createFromXML($xml);

// Chose a generator. You can generate DHTML or a Listbox
//$tree = new HTML_TreeMenu_Listbox($menu);
$tree = new HTML_TreeMenu_DHTML($menu);

echo 
$tree->toHTML();

?>
previousSimple example (Previous) (Next) Pagernext

Download Documentation Last updated: Tue, 02 Jun 2009
Do you think that something on this page is wrong? Please file a bug report or add a note.
User Notes:
There are no user contributed notes for this page.