English 中文(简体)
Need help replicating directory structure with ColdFusion and jsTree
原标题:

I am using this new jQuery plugin called jsTree www.jstree.com and using the HTML datasource.
I am also using ColdFusion 7 with cfdirectory and filtering out files, so just dirs. I need to recreate the directory structure in the image, well any dir structure I give it actually. I am having a heck of a time with the logic. variables.imageDirectoriesLen = 8 in this scenario cause I am outputting from the middle of the actual file path, not from begining.

Thanks for the help.
Derek

alt text

this is what I have so far

<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>&nbsp;</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>&nbsp;</ins>#clientImageDirsFilter.name#</a>
        <ul>
</cfif>

最佳回答

I use a slightly modified version of the recursive function Camden wrote. It should do what you want.

<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>
问题回答

暂无回答




相关问题
JQuery AJAX .load - flash chart doesnt load in IE

An IE issue has me completely stumped. I have a coldfusion page that uses JQuery s AJAX .load function to load in a new flash file that is generated by coldFusion s cfchart tag. This works completely ...

Best Coldfusion Library for OpenID [closed]

I am getting ready to start a project that requires using OpenID within Coldfusion 8. I have found a number of different options and was wondering what has worked the best, get s the most support, ...

Find ColdFusion Generated ID

Is there a way to find the elements generated by ColdFusion s <CFLayout> and <CFLayoutArea> tags? These tags: <cflayout type="tab" name="MyAccount"> <cflayoutarea name="...

ColdFusion COM error

I am upgrading from CF4.5 to CF8. Calls to COM dll s that used to work in version 4.5 now throw a "Complex object types cannot be converted to simple values.." error. The COM object has a few arrays ...

What s the best way to write engine-specific CFML code?

Sometimes it is necessary to write different code for Adobe ColdFusion vs Railo vs OpenBD, due to differences in implementation. Do people have a specific method that they use for this? For example, ...

热门标签