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. /// $treeMenu->Debug(false);
  26. ## *** set postback method: "get", "post" or "ajax"
  27. // $treeMenu->SetPostBackMethod('ajax');
  28. ## *** set variables that used to get access to the page (like: my_page.php?act=34&id=56 etc.)
  29. /// $treeMenu->SetHttpVars(array('id'));
  30. ## *** show number of subnodes to the left of every node - false|true
  31. /// $treeMenu->ShowNumSubNodes(false);
  32. ## *** show 'expand all' and 'collapse all' buttons - false|true
  33. /// $treeMenu->ShowExpandCollapseAllButtons(false);
  34. ## *** set effect for expanding/collapsing nodes - none|slow|normal|fast|integer number - delay in ms
  35. /// $treeMenu->SetAnimationEffect("normal");
  36. ## *** use an anchor to navigate to treemenu object after a node is clicked - true|false
  37. /// $treeMenu->UseAnchor(false);
  38. ## *** create the anchor automatically - true|false
  39. /// $treeMenu->CreateAnchorAuto(false);
  40. ## *** if the CreateAnchorAuto is set to true you have to create the anchor manually
  41. /// <a name="treemenu"></a>
  42. ## *** set TreeMenu direction: ltr - left-to-right or rtl - right-to-left
  43. /// $treeMenu->SetDirection('ltr');
  44.  
  45. ## +---------------------------------------------------------------------------+
  46. ## | 3. Adding nodes:                                                          |
  47. ## +---------------------------------------------------------------------------+
  48. ## *** add nodes
  49. ## arguments:
  50. ## arg #1 - node's caption
  51. ## arg #2 - file associated with this node (optional)
  52. ## arg #3 - icon associated with this node (optional)
  53. ## Example 1: $treeMenu->AddNode('Title');
  54. ## Example 2: $treeMenu->AddNode('Title', 'text.txt');
  55. ## Example 3: $treeMenu->AddNode('Title', 'text.txt', 'icon.gif');
  56.  
  57. $root = $treeMenu->AddNode('Title');
  58. $son = $root->AddNode("Son's Title");
  59. $second = $root->AddNode("2nd son's Title", "index.html");
  60.  
  61. ## *** associate a tab with HTML code snippet:
  62. /// $son->SetInnerHTML("<b><i><span onclick=alert('How do you do?')>HTML</span></i> code snippet</b>");
  63. ## *** open a node in a new window
  64. /// $second->OpenNewWindow(true);
  65. ## *** set a tooltip for a node
  66. /// $son->SetTooltip("Son tab's tooltip");
  67. ## *** sort node's subnodes by name (recursively - true|false)
  68. /// $root->SortByName(true);
  69. ## *** set sub-node which will be selected by default when you click on a node
  70. /// $root->SetDefaultNode($son);
  71.  
  72. ## +---------------------------------------------------------------------------+
  73. ## | 4. Building tree menu from contents of a folder:                                                          |
  74. ## +---------------------------------------------------------------------------+
  75. ## *** build a tree menu from contents of a folder
  76. /// $treeMenu->BuildFromFolder('styles');
  77. ## *** use default icons for folder nodes - false|true
  78. /// $treeMenu->UseDefaultFolderIcons(false);
  79. ## *** use default icons for file nodes - false|true
  80. /// $treeMenu->UseDefaultFileIcons(false);
  81.  
  82. ## +---------------------------------------------------------------------------+
  83. ## | 5. Draw TreeMenu:                                                      |
  84. ## +---------------------------------------------------------------------------+
  85. $treeMenu->ShowTree();
  86. $treeMenu->ShowContent();
  87.    
  88. ?>