TreeView

Version 2.0

 

Description:

This component class is used to create a tree with expandable nodes.

 

Usage:

  1. Include the “tree_view.php” file into the PHP script you wish to write the tree.

e.g.  include(“path/to/tree_view.php”)

 

  1. Instantiate the TreeView class.

e.g.  $TreeView = new TreeView;

 

  1. Set the following TreeView class public variables:
    1. $TreeView->Class = (String)

The name of the style sheet class that defines the styles for the tree.

 

    1. $TreeView->ImagePath = (String)

The relative path to the tree images.

 

    1. $TreeView->Checkboxes = (Boolean)

If true, checkboxes will be written for use in submitting a form.

 

    1. $TreeView->QueryString = (String)

The query string to append to each of the expand node URLs.

 

    1. $TreeView->Style = (Number)

0 = Text only

1 = Defined icons and text

2 = Plus\minus images and text

3 = Plus\minus images, icons, and text

4 = Tree lines, plus\minus images, text

5 = Tree lines, plus\minus images, icons, text

 

    1. $TreeView->DHTML = (Boolean)

If true, the entire tree will be output to the browser and DHTML will be used to expand and collapse the tree, without refreshing the page.

 

    1. $TreeView->UseSession = (Boolean)

If true, the tree uses PHP session variables instead of query string variables to keep track of the nodes that are open in the tree.

 

 

 

 

 

 

 

 

 

 

 

  1. Add nodes using the AddNode method of the Nodes class.

e.g.  $TreeView->Nodes-> addNode ($strParentKey, $intRelationship, $strKey, $strText, $strImage, $strExpandedImage, $strURL, $strTarget, $strCaption);

 

Where the given variables are defined as the following:

         

strParentKey the parent node key of which this node is a child

intRelationship (1) if root, (2) otherwise

strKey the unique key of this node

strText the node's text string or title to display in the tree

strImage the filename and extension of the image

strExpandedImage the filename and extension of the image when the node is expanded

strURL the address of the file to retrieve when the node is clicked

strTarget the frame name for the URL to be displayed

strCaption the text to display when the mouse hovers over the link

 

  1. (Optional) Set the public variable for each node added to the Nodes class:

NOTE:  This must be done before each node that is desired to change style is added.

    1. $TreeView->Nodes->ForeColor = (String)

The hexadecimal color code for the text of the node.

    1. $TreeView->Nodes->BackColor = (String)

The hexadecimal color code for the text of the node.

    1. $TreeView->Nodes->Bold = (Boolean)

If true, the node’s text will be bolded.

 

  1. To write the tree simply call the Show method of the TreeView class.

e.g.  $TreeView->Show();