Here is some code that implements what Ivalverdeb describes.
Download the TreeMenu scripts from
http://www.phpguru.org/static/treemenu.html
Create a label and name it Label_TreeMenu.
Add a "Server" "Before Show" "Custom Code" event, and insert the code below, between the //-- Start Here --- and // --- End Here ---.
upload the Images, Treemenu.php and treemenu.js scripts along with the CCS generated pages. If you copy them to the CCS Project folder, they will be uploaded when the project is published.
//Custom Code @70-48EC3426
// -------------------------
global $Label_TreeMenu;
// ---- Start here ---- Omit lines above ---
// Build a TreeView from a database.
// Interface phpguru.com's TreeMenu to CCS.
http://www.phpguru.org/static/treemenu.html
// 5-18-05 jnorris
// DB table requires a branch, parent_branch, and contents columns.
// I'm also filtering by UserID for my application. Adjust as necessary.
// Get UserID for use with query...
$UserID = CCGetFromGet("UserID",0);
if($UserID > 0) {
require_once('./TreeMenu.php');
$icon = 'folder.gif';
$expandedIcon = 'folder-expanded.gif';
$i = 0; //index
// connect to DB...
$db = new clsDBConnection1();
$SQL = "SELECT * FROM box WHERE box_client_id = ".$UserID;
$db->query($SQL);
$Result = $db->next_record();
$menu = new HTML_TreeMenu();
while($Result > 0) {
// populate variables from db...
$branch = $db->f("box_compartment");
$branch_parent = $db->f("box_parent_compartment");
$branch_value = $db->f("box_value");
// Build tree...
if($branch_parent) {
$$branch = &$$branch_parent->addItem(new HTML_TreeNode(array('text' => $branch, 'link' => $branch_value, 'icon' => $icon, 'expandedIcon' => $expandedIcon)));
} else {
$$branch = new HTML_TreeNode(array('text' => $branch, 'link' => $branch_value, 'icon' => $icon, 'expandedIcon' => $expandedIcon));
$tree[$i++] = &$$branch; // Indexed reference for final tree consruction.
}
unset($branch);
unset($branch_parent);
unset($branch_value);
$Result = $db->next_record();
} //wend
$db->close();
// FOREACH was uncooperative for some reason...
$temp = 0;
while($temp < $i){
$menu->addItem($tree[$temp]);
$temp++;
}
// Stuff menu DHTML into the label...
$treeMenu = &new HTML_TreeMenu_DHTML($menu, array('images' => './images', 'defaultClass' => 'treeMenuDefault'));
$Label_TreeMenu->SetValue($treeMenu->toHTML());
} else { // Error message stuffed into label instead...
$Label_TreeMenu->SetValue("TREEMENU: No UserID");
} //endif
// --- End here --- Omit lines below ----
// -------------------------
//End Custom Code