Simple example
<?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'=>'folder.gif', 'text' => "Style #$i"))
);
$menu_pays->addItem(
new HTML_TreeNode(array('icon'=>'folder.gif', 'text' => "Country #$i"))
);
$menu_restaurants->addItem(
new HTML_TreeNode(array('icon'=>'folder.gif', 'text' => "Restaurant #$i"))
);
$menu_plats->addItem(
new HTML_TreeNode(array('icon'=>'folder.gif', 'text' => "Menu #$i"))
);
}
$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();
?>
Prev | HTML_TreeMenu | Next |
Installing the files | PEAR Manual | Tree-construction methods |