根据上传到服务器文件夹的 XML 数据填充 jsTree
tl:dr 如何根据文件夹位置而不是确切的 XML url 填充 jsTree?
我正在为这个项目寻找一些方向。
目前,我正在尝试将硬盘驱动器的文件结构复制为 XML 文件,并使用网络服务器上的 jsTree 重新创建它们,以获得完全独立的文件结构版本。我有一些 python 脚本,它输出形成为 jsTree 的 XML 文件,并自动上传到服务器上的文件夹。问题是现在我有点迷失了,因为我必须手动将每个 XML 文件输入到 jsTree 代码中才能显示,所以我有多个这样的条目:
$("#tree1")
.jstree({
"plugins" : [ "themes", "xml_data", "ui", "search", "types" ],
"xml_data" : {
"ajax" : {
"url" : "./XML_DATA/DRIVE1.xml"
},
"xsl" : "nest"
},
我在文档中看到,文件夹不是由直接文件填充,而是由文件夹填充通过“server.php”,但 php 代码中没有任何位置它指向任何目录或文件。在考虑了这个问题之后,我想到了一些解决方案,并且可以对它们使用一些建议:
我应该尝试编写 php 代码来自动查看我的 XML_DATA 文件夹来上传每个 XML 文件吗?我是否应该将所有 XML 上传到 mySQL 并基于此填充我的树? javascript 应该是在服务器文件夹中查找 XML 文件的代码吗?
所有 XML 都以相同的方式形成,但服务器上的 XML 文件数量将会增加,并且必须刷新,并且它们将被更改覆盖。 任何方向将不胜感激,谢谢。
tl:dr How can I populate jsTree based on a folder location instead of an exact XML url?
I'm looking for a little direction on this project.
Currently I am trying to copy file structures of hard drives as XML files and recreate them using jsTree on the webserver for a completely independent version of the file structure. I have some python script that outputs XML files that are formed to jsTree and automatically uploads to a folder on the server. The problem is now I am a little lost because I have to manually enter each XML file into jsTree code for it to display so I have multiple entries like this:
$("#tree1")
.jstree({
"plugins" : [ "themes", "xml_data", "ui", "search", "types" ],
"xml_data" : {
"ajax" : {
"url" : "./XML_DATA/DRIVE1.xml"
},
"xsl" : "nest"
},
I see in the documentation that instead of populated by the direct file the folders are populated by "server.php" but no where in the php code does it point to any directories or files. After considering the problem I thought of a few solutions and could use some advice on them:
Should I be trying to write php code to automatically look through my XML_DATA folder to upload each XML file? Should I just upload all the XML to mySQL and populate my tree based on that? Should the javascript be the code looking through the server's folder for XML files?
All the XML is formed the same way but the number of XML files on the server will increase and will have to be refreshed as well as they will be overwritten with changes.
Any direction would be appreciated, thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您想使用 jstree 的哪些功能?
如果您只想拥有一个与文件系统上的内容相匹配的可扩展树。然后,您可以指向读取文件结构并输出基于
的树的 php 页面,然后对其应用 jstree。
但既然听起来您已经用 python 编写了 XML 生成器,为什么不直接向您的 Web 服务器添加 python 支持,并将该 XML 文件提供给 jstree 实例呢?
最后一个最糟糕的选择是简单地指向网络服务器上生成的 XML 文件。您不会有任何动态能力,但您将在 jstree 中获得 XML 文件。
What functions of jstree are you trying to use?
If you're just wanting to have an expandable tree matching what's on your filesystem. Then you can either point to a php page that reads your file structure and outputs an
<UL><LI>
based tree and then apply jstree to it.But since it sounds like you already wrote the XML generator in python, why not just add python support to your webserver, and serve up that XML file to the jstree instance?
The last worst option is to simply point to the generated XML file on your webserver. You won't have any dynamic abillity, but you'll get the XML file in jstree.