Javascript validator
Web page editor
This manual page shows the basic steps to get HTML_TreeMenu working.
Before using HTML_TreeMenu, you'll have to put some files in your project's htdocs directory:
TreeMenu.js
images
You can get on your harddrive in $pear_data_dir/HTML_TreeMenu or online at the PEAR CVS-Web.
<?php
require_once 'HTML/TreeMenu.php';
$menu_styles = new HTML_TreeNode(array('text'=>'Styles'));
$menu_pays = new HTML_TreeNode(array('text'=>'Countries'));
$menu_restaurants = new HTML_TreeNode(array('text'=>'Restaurants'));
$menu_plats = new HTML_TreeNode(array('text'=>'Menus'));
for ($i = 1; $i < 10; $i) {
$menu_styles->addItem(new HTML_TreeNode(array('icon'=>'Image '.($i 0))));
$menu_pays->addItem(new HTML_TreeNode(array('icon'=>'Image '.($i 10))));
$menu_restaurants->addItem(new HTML_TreeNode(array('icon'=>'Image '.($i 20))));
$menu_plats->addItem(new HTML_TreeNode(array('icon'=>'Image '.($i 30))));
}
$menu = new HTML_TreeMenu();
$menu->addItem($menu_styles);
$menu->addItem($menu_pays);
$menu->addItem($menu_restaurants);
$menu->addItem($menu_plats);
// Chose a generator. You can generate DHTML or a Listbox
$tree = new HTML_TreeMenu_DHTML($menu);
echo $tree->toHTML();
?> |
Actually, you have three different methods to build the tree:
This is the 'hard' way, like the example above. You have to set each node by hand.
You can import a formatted XML file into the tree structure. It supports string of XML_Tree object :)
Example 47-156. XML Format
|
Example 47-157. Example with a string (not tested)
|
Javascript validator
Web page editor