Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

sorting/grouping results with CFDIRECTORY

New Here ,
May 05, 2008 May 05, 2008
I am using cfdirectory to list all of the files in a certain directory and sorting them desc by datelast modified. Here's the page: http://www.ucmo.edu/news/releases/releases.cfm?y=2008

What I would like to do is sort them further by month and automatically create headings such as May, April, March, etc. I know how to get the monthasstring (in comments below) but can't get them grouped.

Here's what I use to display this page now:

<cfdirectory action="LIST" name="rel" directory="mydir/mysubdir" sort="month(datelastmodified) desc">

<ul>
<cfoutput query="rel">
<!--- #monthasstring(month(datelastmodified))#<br> --->

<li><img src="/home_images/icons/acrobat.gif" width="16" height="16" class="icon" alt=""> <a href="#y#/#name#" target="_blank">#replace(name,".pdf","")#</a></li>

</cfoutput>
</ul>


469
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 05, 2008 May 05, 2008
use a QoQ (query of queries) on your cfdirectory query to get the info
you need plus add any extra columns you need to be able to sort/group as
necessary.


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2008 May 05, 2008
I've tried that to but can't seem to figure out the QoQ either. I'm still unable to group by month. I want it to look like:


May
My pdf1
My pdf2

April
My pdf3
My pdf4
My pdf5
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 05, 2008 May 05, 2008
LATEST
You will need to populate a column with month names before you can group by it. My approach would be:

1. Do a Q of Q where I select the fields I need from the cfdirectory query, plus some contstant string as the month name.
2. Loop through this query and set the month name column to the proper value.
3. Output my data from this query, grouping on the month name column.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources