ApPHP TreeMenu Pro - Example of Code

Show Plain Text »
  1. <?php
  2.  
  3. ## +---------------------------------------------------------------------------+
  4. ## | 1. Creating & Calling:                                                    |
  5. ## +---------------------------------------------------------------------------+
  6. ## *** define a relative (virtual) path to treemenu.class.php file
  7. define ('TREEMENU_DIR', '');
  8. ## *** include TreeMenu class
  9. require_once(TREEMENU_DIR.'treemenu.class.php');
  10. ## *** create TreeMenu object
  11. $treeMenu = new TreeMenu();
  12.  
  13. ## +---------------------------------------------------------------------------+
  14. ## | 2. General Settings:                                                      |
  15. ## +---------------------------------------------------------------------------+
  16. ## *** set unique identifier for TreeMenu
  17. ## *** (if you want to use several independently configured TreeMenu objects on single page)
  18. $treeMenu->SetId(1);
  19. ##  *** set style for TreeMenu
  20. ##  *** "default" or "xp" or "vista" or "paneled" or your own style
  21. $treeMenu->SetStyle('paneled');
  22. ## *** set TreeMenu caption
  23. $treeMenu->SetCaption('ApPHP TreeMenu v'.$treeMenu->Version());
  24. ## *** show debug info - false|true
  25.  
  26. ## +---------------------------------------------------------------------------+
  27. ## | 3. Adding nodes:                                                          |
  28. ## +---------------------------------------------------------------------------+
  29. ## *** add nodes
  30. ## arguments:
  31. ## arg #1 - node's caption
  32. ## arg #2 - file associated with this node (optional)
  33. ## arg #3 - icon associated with this node (optional)
  34. ## Example 1: $treeMenu->AddNode('Title');
  35. ## Example 2: $treeMenu->AddNode('Title', 'text.txt');
  36. ## Example 3: $treeMenu->AddNode('Title', 'text.txt', 'icon.gif');
  37.  
  38. $root = $treeMenu->AddNode('Title');
  39. $son = $root->AddNode("Son's Title");
  40. $second = $root->AddNode("2nd son's Title", "index.html");
  41.  
  42. ## +---------------------------------------------------------------------------+
  43. ## | 5. Draw TreeMenu:                                                      |
  44. ## +---------------------------------------------------------------------------+
  45. $treeMenu->ShowTree();
  46. $treeMenu->ShowContent();
  47.    
  48. ?>