[thelist] CFTREE item display order

scott.brady at homeqonline.com scott.brady at homeqonline.com
Fri Mar 30 17:09:32 CST 2001

I have a cftree (in Cold Fusion, obviously) which is displaying a folder
structure (which is developed from a query on a  database) and a list of files
in each of those folders (which is done using < cfdirectory >.

I'd like to get the display of the tree items such that the sub-folders are
listed above the files in a folder.  For the root directory, this works fine by
putting the file treeitems after the sub-folder treeitems (probably because I
don't have to worry about determining the treeitem's parent).  For any other
directory, though, the files appear above the folders, even though the
sub-folder treeitems are above the files in the code.

This is on an intranet site, so I can't provide a URL, and the code is pretty
long, so I won't post it here.

But, here's the basic code structure:

1) cftree tag
2) cftreeitem for root directory
3) loop along directory query
     a) Generate treePath list (basically, a list of the current directory's
path from the root)
     b) Set treeParent variable for this folder
     c) cftreeitem for folder, with parent folder (or root, if applicable) as
treeitem parent
     d) Loop along treePath list, run query on folder to set the server path for
that directory
     e) Get folder contents with cfdirectory
     f) Loop along folder contents (files only)
          i) Get the file's ID number from the database
          ii) cftreeitem for file (with its folder as the parent)
4) Get root directory's contents with cfdirectory
5) Loop along root directory contents (files only)
     a) Get the file's ID number from the database
     b) cftreeitem for file (with root directory as parent)

I don't know how much clearer that is.

I guess what I really need to know is what determines the order the tree items
appear relative to other tree items with the same parent?  I assumed it would be
the order they are in the code, but something in my code seems to be affecting

Thanks for any guidance.  This isn't a really crucial issue, it's just one of
those small things that bugs me.


More information about the thelist mailing list