Tree menu for Sitemagic CMS
The tree menu control is great for presenting structured information in a hierarcy - for instance a folder structure as shown below.
A tree menu can be constructed using the SMTreeMenu
class as demonstrated below. The tree menu created will be identical to the image above.
$id = "MyExtensionTreeMenu"
// Create tree menu and set it to automatically post back selected node
$tree = new SMTreeMenu($id);
// Create all items with the following arguments: Unique ID, title, and value
$files = new SMTreeMenuItem($id . "item1", "files", "files");
$downloads = new SMTreeMenuItem($id . "item2", "downloads", "files/downloads";
$editor = new SMTreeMenuItem($id . "item3", "editor", "files/editor");
$gallery = new SMTreeMenuItem($id . "item4", "gallery", "files/gallery");
$cars = new SMTreeMenuItem($id . "item5", "cars", "files/gallery/Cars");
$images = new SMTreeMenuItem($id . "item6", "gallery", "files/images");
// Append items to files root item
$gallery->AddChild($cars); // cars item goes into gallery item instead of files item
// Append root node to tree (we could of course have multiple root nodes)
// Handle item selection
if ($tree->PerformedPostBack() === true)
// Get selected value - could retur e.g. files/gallery/Cars
$value = $tree->GetSelectedValue();
// Do something with selected value here..