> > I'm interested in developing a web-based document-viewing intranet page
> > (using CF 4.0.1) to allow users to navigate multiple directory levels on
> > the server.  Word and Acrobat documents in these directories could then
be
> > launched from the browser.
> >
> > So far, I haven't found any custom tags or tutorials on this subject,
> > which must be a fairly common activity for CF developers.  There is a
tag
> > at Allaire's site called CF_FILECHOOSER, but it loads the entire
directory
> > structure into a CFTREE applet - My users won't want to wait that long
to
> > see the directory each time.
> >
> > Please describe how you might do/already did this, or perhaps provide
some
> > code examples or references.

This is pretty straightforward using CFDIRECTORY.  Start with a root
directory, do a CFDIRECTORY to get its contents, then display direct links
to files entries; for directories, you create links which point back at the
same template and pass the new directory name and then do another
CFDIRECTORY on the subdirectory.  There's a field called 'type' returned in
the CFDIRECTORY query which tells you if an entry is a file or directory.
When you do a CFDIRECTORY, you'll also see the standard DOS "." (current
directory) and ".." (parent directory).  You could probably suppress the
current directory link, and if you're in the root directory, suppress the
parent link.  Otherwise, once a user has navigated down into a subdirectory
display the link to the parent so that they may climb back up.

Check out the CFDIRECTORY documentation.  You'll see that you can use a
filter.  For example "*.pdf" if you wanted to only display files with that
extension.  You might use this to refine what file listings a user sees.
When you do a CFDIRECTORY, you'll get things like directory entry name (file
name or subdirectory name), file size, date the file was last updated,
attributes.  You could choose to display any or all of those items for each
entry.  You can also tell CFDIRECTORY to sort in ascending or descending
order on any of those fields, so you might implement a Windows Explorer-like
interface that lets a user click on a colum header and sort the files by
name or date or size.

An quick and dirty way to do all this, if you don't need the filtering or
sorting features, would be to simply permit directory browsing within the
web server's setup.  Then point your users to the root directory and let 'em
roam.  You may have to use NT ACLs to keep those users confined to the tree
below the root, however.

Jim


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to