Getting Started with ApPHP TreeMenu (v3.0.0 or above)

Common Notices

We use:
## - for comments
/// - for lines, that may be uncommented (optional)

Common notes.
• Please, use a $treeMenu->Debug(true); to debug your application
• Do not place ApPHP TreeMenu code inside another HTML Form: <form>...</form>

Getting Started

Step 1. Creating TreeMenu object

Make sure you define a valid relative (virtual) path to the treemenu.class.php file.
## *** define a relative (virtual) path to treemenu.class.php file
define ('TREEMENU_DIR', '');
## *** include TreeMenu class
There are two classes in this package: the TreeMenu class creates the tree structure and the Node class is used for each node. First you must create a TreeMenu object.
## *** create TreeMenu object
$treeMenu = new TreeMenu();

Step 2. General Settings

Set unique numeric (integer-valued) identifier for TreeMenu.
## *** (if you want to use several independently configured 
TreeMenu objects on single page)
Set a style for TreeMenu.
##  *** "default" or "xp" or "vista" or "paneled" or your own style
Set a caption for TreeMenu.
$tm_caption = 'ApPHP TreeMenu Pro v'.$treeMenu->Version();
Defines whether the debug mode is turned on or not.
## *** show debug info - false|true
You may define a method for data submission type (PostBack type). Possible values are: "get", "post" or "ajax".
## *** set form submission type: "get", "post" or "ajax"
If you need to store parameters, that were passed to your page in URL, you have to save them between calls of TreeMenu by using following method: SetHttpVars(). This guarantees that these parameters will not be lost while your work with TreeMenu control.
## *** set variables that used to get access to the page 
(like: my_page.php?act=34&id=56 etc.)
$treeMenu->SetHttpVars(array('act', 'id'));
There is also an option to display number of sub-nodes to the left of every node in brackets (like: MainNode(10)).
## *** show number of subnodes to the left of every node - false|true
'Expand all' and 'Collapse all' buttons may be displayed.
*** show 'expand all' and 'collapse all' buttons - false|true
SetAppearEffect function is used to employ special visual effects when the nodes appear/disappear. You can also set a speed for the appearance to 'fast', 'normal' or 'slow' or a number of milliseconds.
*** set effect for expanding/collapsing nodes - none|slow|normal|fast|integer number - delay in ms
You can use an anchor to navigate to the treemenu after a node is clicked.
## *** use anchor
The anchor can be created automatically.
## *** create anchor automatically
If the previous option is set to false, you have to create the anchor manually by putting this line anywhere in the HTML-code.
<!-- create anchor manually -->
<a name='treemenu'></a>
The TreeMenu supports both (ltr) left-to-right and (rtl) right-to-left layout. To change that use the SetDirection function.
##  set TreeMenu direction: left-to-right or right-to-left

Step 3. Adding nodes.

Now you can add nodes by using the method AddNode()
## *** add nodes
## arguments:
## arg #1 - node's caption
## arg #2 - file associated with this node (optional)
## arg #3 - icon associated with this node (optional)
## Example 1: $treeMenu->AddNode('Title');
## Example 2: $treeMenu->AddNode('Title', 'text.txt');
## Example 3: $treeMenu->AddNode('Title', 'text.txt', 'icon.gif');
The method returns Node object which supports AddNode() method as well so you can create multilevel tree-menu.
## *** add nodes

$pictures = $treeMenu->AddNode('Pictures');
$europe = $pictures->AddNode('Europe');
$america = $pictures->AddNode('America');

$europe->AddNode('Eiffel Tower','content/paris.jpg','img/france.gif');
$europe->AddNode('Big Ben','content/london.jpg','img/britain.gif');
$colosseum=$europe->AddNode('The Colosseum','content/rome.jpg','img/italy.jpg');


You may associate nodes not with files but with HTML code snippets.
## *** associate nodes with HTML code snippets
$america->SetInnerHTML("<div onclick='alert(\"Alert\")'>HTML</div> code snippet");
A node may open its file in a new window.
## *** open a node in a new window
You can also set a tooltip for a node.
## *** set a tooltip for a node
$america->SetTooltip('Ray Bradbury\'s homeland');
You can sort the sub-nodes of a given node by name.
*** sort node's subnodes by name (recursively - true|false)
There is also an option to specify which of the sub-nodes will be selected by default when you click on the given node.
## *** set sub-node which will be selected by default when you click on a node

Step 4. Scanning content of a folders

Build a tree menu from contents of a folder.
Use default icons for folder nodes: false or true.
Use default icons for file nodes: false or true.

Step 5. Drawing TreeMenu

Now you can draw tree-menu on the screen.
## *** drawing tree-menu
Create Your Free Account
Please remember that this information is essential to use our services correctly.
After creating the account you will be able to download all of our FREE products.
Fields marked with * are mandatory

Please send me information about updates, new products, specials and discounts from ApPHP!
We recommend that your password should be at least 6 characters long and should be different from your username/email. Please use only letters of the English alphabet to enter your name.

Your e-mail address must be valid. We use e-mail for communication purposes (order notifications, etc). Therefore, it is essential to provide a valid e-mail address to be able to use our services correctly.

All your private data is confidential. We will never sell, exchange or market it in any way. Please refer to Privacy Policy.

By clicking "Create Account", you are indicating that you have read and agree to the ApPHP Terms & Conditions.