Reputation: 35724
I'm looking to loop through a query, and would like to use grouping, like one would using cfoutput
. I know CF10 added that support, but is there a script that emulates that behaviour so that items can be iterated easily?
Edit:
There are ways of getting around the lack of grouping in cfloop
, by rearranging cfoutput
tags, so they are not nested. The reason I'm looking for the cfloop
workaround is that when nesting cfoutput
, you need to use the results from the same query. I'd like to use my own QoQ and loop through the result.
Upvotes: 1
Views: 5380
Reputation: 29870
OK, so you want to do this sort of thing:
<cfoutput query="query1">
<!--- stuff --->
<cfoutput query="query2" group="col>
<!--- more stuff --->
<cfoutput>
<!--- still more stuff --->
</cfoutput>
<!--- almost the last stuff --->
</cfoutput>
<!--- last stuff --->
</cfoutput>
?
And the second loop gives you an error:
Invalid tag nesting configuration.
A query driven cfoutput tag is nested inside a cfoutput tag that also has a query attribute. This is not allowed. Nesting these tags implies that you want to use grouped processing. However, only the top-level tag can specify the query that drives the processing.
You should be able to revise that to:
<cfloop query="query1">
<cfoutput>
<!--- stuff --->
</cfoutput>
<cfoutput query="query2" group="col>
<!--- more stuff --->
<cfoutput>
<!--- still more stuff --->
</cfoutput>
<!--- almost the last stuff --->
</cfoutput>
<cfoutput>
<!--- last stuff --->
</cfoutput>
</cfloop>
There's another option to emulate the group loop if you must. But that's a bunch of thinking and typing I'd rather avoid if poss, so let me know if this approach works first.
Upvotes: 3