Skip to main content
Known Participant
June 10, 2010
Question

nested news part 2

  • June 10, 2010
  • 1 reply
  • 284 views

I have it kind of working but i need to do a second group for the months.

2010
      June News Item1
     June News Item2
     June News Item3
     April News Item4

I need to group so

2010
      June

        News Item1

        News Item2

        News Item3

   April

         News Item4

This is what I have so far

<cfquery name="qGetResults" datasource="mysource"> SELECT * FROM results </cfquery>

<cfdump var="#qGetResults#">

<cfoutput query="qGetResults" group="year">


#year# <br />

        <cfoutput>#MonthAsString(Month(result_date))# #title#<br /></cfoutput>


</cfoutput>

thanks.

    This topic has been closed for replies.

    1 reply

    Inspiring
    June 10, 2010

    First, put an order by clause in your query.  Otherwise the group attribute of cfoutput won't work properly.

    Next, you can use the group attribute more than once on the same query.  It goes something like this.

    <cfoutput query = "abc" group = "field1">

    #field1#

    <cfoutput group = "field2">

    #field2#

    <cfoutput>

    #ungrouped data#

    closing tags.