Enable jQueryFileTree to support custom trees and Chinese characters

Source: Internet
Author: User
For how to use the jQueryFileTree plug-in, click here JQueryFileTree only supports listing out files and does not support Chinese Characters1. How can I make it support custom lists? Save the following code as a UTF-8 code for custom. php <? Php
Header ("Content-Type: text/html; charset = UTF-8 ");
$ Dir = trim ($ _ POST ['dir'], "/");
 
// Tree Structure
$ Data = array (
"Folder 1" => array (
"File1" => "item1 ",
"File2" => "item2 ",
"Folder11" => array (
"File6" => "item6"
)
),
"Folder2" => array (
"File3" => "item3 ",
"File4" => "item4"
),
"Project" => "item5"
);
 
// Process
$ N_data = $ data;
$ N_dir = explode ("/", $ dir );
If ($ dir! = ""){
Foreach ($ n_dir as $ v ){
$ N_data = $ n_data [$ v];
}
}
Echo "<ul class = \" jqueryFileTree \ "style = \" display: none; \ "> ";
Foreach ($ n_data as $ key => $ value ){
If (is_array ($ value ))
Echo "<li class = \" directory collapsed \ "> <a href = \" # \ "rel = \"". $ dir. "/". $ key. "/". "\"> ". $ key. "</a> </li> ";
Else
Echo "<li class = \" file ext _ $ ext \ "> <a href = \" # \ "rel = \"". $ value. "\"> ". $ key. "</a> </li> ";
}
Echo "</ul> ";
?>

 

Call on the call page

$ ('# Container_id2'). fileTree ({
Root :'/',
Script:'m M. php ',
ExpandSpeed: 1000,
CollapseSpeed: 1000,
MultiFolder: false
}, Function (file ){
Alert (file );
});

 

2. Make it support Chinese files-Modify the jQueryFileTree. js and jQueryFileTree. php files

Call

$ ('# Container_id'). fileTree ({
Root :'./',
Script: 'jqueryfiletree. php ',
ExpandSpeed: 1000,
CollapseSpeed: 1000,
MultiFolder: false
}, Function (file ){
Alert (file );
});

 

View demo

Download example

 

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.