views:

157

answers:

1

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>

+1  A: 

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>
jfrobishow
AWESOME! Thanks. Don't think I found that while searching. It does indeed work. I guess I was thinking too hard.
Derek