Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to list local directory structure by using <cftree>?

Status
Not open for further replies.

oceandeep

IS-IT--Management
Jul 6, 2000
69
GR
Could anybody here tell me how to list the local directory structure? By using <cftree>.

Thanks a lot!
 
You mean the client's directory structure by &quot;local&quot;? That's quite hard, you will need an ActiveX component to do that, or <input type=&quot;file&quot;>, which opens a file dialog box.
If you mean the directory on the server, that's quite easy:

<cfdirectory action=&quot;LIST&quot; directory=&quot;C:\inetpub\ name=&quot;MyList&quot;>

The result behaves like any ordinary query.

Hope this helps...

<webguru>iqof188</webguru>
 
Thanks a lot!
But what I am actually doing now is to develop a online virtual directory. People can upload, download... such kind of things.
I am using database to keep the info of each folder the user created. There have, say, fd_parent propertie to point to the folder's parent folder, fd_child(boolean) to tell if the folder has sub-folder.
What I am trying to do now is to list the directories out and branch them out by using <cftree> or some other tags.
Any suggestions from you are highly appreciated.
Thanks!
Albert
 
In the <cftreeitem> tag you can specify which record should be the parent of a certain item. If you do a clever query (my best bet is with a GROUP BY), you should be able to group all the child elements under the parent element. If you need more help, please be more specific on your database design. Good luck :)


<webguru>iqof188</webguru>
 
Hi, friends, it worked!

The code is here:
<cfquery datasource=&quot;TPVWDDB&quot; name=&quot;getFolder&quot;>
SELECT *
FROM folder_t
WHERE memID = '#session.memID#'
</cfquery>

<cfform action=&quot;dirAct.cfm&quot; method=&quot;POST&quot; enablecab=&quot;Yes&quot;>
<cftree name=&quot;FolderList&quot; width=&quot;470&quot; bold=&quot;No&quot; italic=&quot;No&quot; border=&quot;Yes&quot; hscroll=&quot;Yes&quot; vscroll=&quot;Yes&quot; required=&quot;No&quot; completepath=&quot;No&quot; appendkey=&quot;Yes&quot; highlighthref=&quot;Yes&quot;>
<cfloop query=&quot;getFolder&quot;>
<cftreeitem display=&quot;#fd_name#&quot; value=&quot;#fd_id#&quot; parent=&quot;#fd_parent#&quot; img=&quot;image/fclosed.jpg&quot; imgopen=&quot;image/fopen.jpg&quot;>
<cfquery datasource=&quot;TPVWDDB&quot; name=&quot;getFile&quot;>
SELECT *
FROM file_t
WHERE fdID = '#fd_id#'
</cfquery>
<cfloop query=&quot;getFile&quot;>
<cftreeitem display=&quot;#file_name#&quot; value=&quot;#fileID#&quot; parent=&quot;#fdID#&quot; img=&quot;image/dot.jpg&quot;>
</cfloop>
</cfloop>
</cftree>
<input type=&quot;Submit&quot; value=&quot;Submit&quot;>
</cfform>

At first, I did like this:

<cftreeitem query=&quot;getFolder&quot; display=&quot;fd_name&quot; value=&quot;fd_id&quot; parent=&quot;fd_parent&quot; img=&quot;image/fclosed.jpg&quot; imgopen=&quot;image/fopen.jpg&quot;>, and I didn't use <cfloop>, but it cannot work the way I want.
So far, I am still quite not sure what is the different I use <cfloop> and query property in <cftreeitem>, but anyway, it worked finally!

But here, I still got some problems, how can I pass the folder/file value to the next page if I want to do some operations on that folder/file?
Sorry, I feel quite clumsy at ColdFusion.

I could say nothing but thanks to you guys' generous help. Thank you very mush!
Albert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top