我正在使用这个名为jsTree www.jstree.com的新jQuery插件并使用HTML数据源。
我也在使用带有cfdirectory的ColdFusion 7并过滤掉文件,所以只是dirs。
我需要在图像中重新创建目录结构,以及我实际给出的任何目录结构。我对逻辑有一点兴趣。
变量.imageDirectoriesLen = 8在这种情况下导致我从实际文件路径的中间输出,而不是从开始输出。
感谢您的帮助 德里克
alt text http://i41.tinypic.com/2yjsirl.png
这是我到目前为止所拥有的
<cfoutput query="clientImageDirsFilter">
<cfset nextLen = 0 />
<cfset nextDir = "" />
<cfset nextRowCnt = currentRow+1 />
<cfset nextDir = clientImageDirsFilter.directory[nextRowCnt] & "\" & clientImageDirsFilter.name[nextRowCnt] />
<cfset nextLen = listLen(nextDir, "\") />
<cfset currLen = listLen(clientImageDirsFilter.directory & "\" & clientImageDirsFilter.name,"\") />
<cfif currLen eq nextLen>
<li rel="folder" id="node_#randRange(1,99999)#"><a href="##"><ins> </ins>#clientImageDirsFilter.name#</a></li>
<cfelseif nextLen lt currLen>
<cfif nextLen eq 0>
#repeatString("</li></ul>",(currLen-nextLen-variables.imageDirectoriesLen))#
</cfif>
<cfelse>
<ul>
<li rel="folder" id="node_#randRange(1,99999)#"><a href="##"><ins> </ins>#clientImageDirsFilter.name#</a>
<ul>
</cfif>
答案 0 :(得分:3)
我使用recursive function Camden wrote的略微修改版本。它应该做你想要的。
<cfset initialDir = "C:\myrootdir">
<cfdirectory directory="#initialDir#" recurse="yes" name="files" sort="type asc">
<cfquery name="test" dbtype="query">
select * from files where name <> 'Thumbs.db'
</cfquery>
<div id="basic_html">
<cfset display(test,initialDir)>
</div>
<cffunction name="display" returnType="void" output="true">
<cfargument name="files" type="query" required="true">
<cfargument name="parent" type="string" required="true">
<cfset var justMyKids = "">
<cfquery name="justMyKids" dbtype="query">
select *
from arguments.files
where directory = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.parent#">
</cfquery>
<ul>
<cfoutput query="justMyKids">
<cfif type is "Dir">
<ul><li><a href="##"><ins> </ins>#Replace(name, "_", " ", "All")#</a> #display(arguments.files, directory & "\" & name)#</li></ul>
<cfelse>
<cfset fileURL = Replace(Replace(directory, initialDir, "", "All"), "\", "", "All") & "/" & name>
<li class="close"><a href="#fileURL#"><img src="http://localhost/globalincludes/interface/includes/js/jquery_plugins/jsTree/file.png" border="0"> #Replace(name, "_", " ", "All")#</a></li>
</cfif>
</li>
</cfoutput>
</ul>
</cffunction>