Using PHP to implement the Windows Explorer-style tree menu _php Tutorial

Source: Internet
Author: User
The following is a tree-like menu with a style similar to Windows Explorer
Include the following script in your page
Also need to intercept some GIF pictures from the Explorer, see the comments in the script
The format of the menu structure file is:
Tree Level|item text|item link|link target|last item in subtree
For example
. Demo Menu|javascript:alert (' This was the demo menu for Treemenu 1.0 ');
.. Catalog 1
... Sub-Directory 1.1
... item 1.1.1|javascript:alert (' Item 1.1.1 ');
... item 1.1.2|javascript:alert (' Item 1.1.1 ');
... item 1.2|javascript:alert (' Item 1.2 ');
... item 1.3|javascript:alert (' Item 1.3 ');
.. Sub-Catalog 2
... item 2.1|javascript:alert (' Item 2.1 ');
... item 2.2|javascript:alert (' Item 2.2 ');
... Sub-directory 2.3
... item 2.3.1|javascript:alert (' Item 2.3.1 ');
... item 2.3.2|javascript:alert (' Item 2.3.2 ');
File:tremenu.inc
PHP Treemenu
/////////////////
Initialize//
/////////////////
$treefile = "Demomenu.txt";//File with menu structure
if (Isset ($PATH _info))
$script = $PATH _info;
Else
$script = $SCRIPT _name;
A picture that intercepts the corresponding location in Windows Explorer
$img _expand = "tree_expand.gif";//shapes such as the Extensible node in Resource Manager +
$img _collapse = "tree_collapse.gif";//shaped as an extension node in the Explorer-
$img _line = "tree_vertline.gif";//Shape like |
$img _split = "tree_split.gif";//Shape like |
$img _end = "tree_end.gif";//Shaped like L
$img _leaf = "tree_leaf.gif";//Shaped like O
$img _SPC = "tree_space.gif";//Blank graph
Here is the menu processing script
$maxlevel = 0;
$cnt = 0;
$FD = fopen ($treefile, "R");
if ($fd ==0) die ("Treemenu.inc:Unable to open File". $treefile);
while ($buffer = Fgets ($FD, 4096))
{
$tree [$cnt][0]=strspn ($buffer, ".");
$tmp =rtrim (substr ($buffer, $tree [$cnt][0]);
$node =explode ("|", $tmp);
$tree [$cnt][1]= $node [0];
$tree [$cnt][2]= $node [1];

http://www.bkjia.com/PHPjc/631785.html www.bkjia.com true http://www.bkjia.com/PHPjc/631785.html techarticle The following is a tree-like menu with a style similar to Windows Explorer to include the following script in your page you also need to intercept some GIF images from the explorer, and see the note in the script ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.