Skip to main content
December 20, 2008
Question

Nested CFOUTPUT group processing...

  • December 20, 2008
  • 2 replies
  • 3294 views
Hi,

I have been using the group attribute of CFOUTPUT for some time now, it's really really helped a lot!

However, I am now in a situation where two separate queries (each of which needs it's own grouping) need to be nested. But, this doesn't seem to be possible because CF throws an error about the query "driving" the process.

See the example code below...

<cfoutput query="foo" group="a">
#foo.a#
<cfoutput query="foo" group="b">
#foo.b#
</cfoutput>

</cfoutput>

This works great, BUT, if I do the following it will fail.

<cfoutput query="foo" group="a">
#foo.a#
<cfoutput query="foo" group="b">
#foo.b#

<cfoutput query="bar" group="c">
#bar.c#
</cfoutput>

</cfoutput>

</cfoutput>


However, for many reasons I NEED to have nested grouping like this and I can't see another way around it. While it is perfectly fine to have queries looped within other queries (usually with CFLOOP) CFLOOP does not support the GROUP attribute like CFOUTPUT does.

If anyone can help I'd really appreciate it. I'm not sure how to get around this issue at all.

Thanks,
Mikey.
    This topic has been closed for replies.

    2 replies

    Inspiring
    December 21, 2008
    Do a union query of queries with foo and bar. select contstants to match up the fields if necessary.
    Inspiring
    December 20, 2008
    I would look for a way to build up a list from each cfoutput separately
    (i.e not nested, using group however you like and 'listAppend()' or
    'valueList()' to build the lists), and then use nested <cfloop
    list="listName" etc> to create the desired output.


    Michael Evangelista, Evangelista Design
    Web : www.mredesign.com Blog : www.miuaiga.com
    Developer Newsgroups: news://forums.mredesign.com
    December 21, 2008
    Hi Dan, that UNION sounds like a good idea for a situation like this, but in my particular instance it's just not possible. I'm curious though, how would grouping work with a UNION query? Is it any different?

    Do you think an issue like this could be resolved if the CFLOOP tag support the GROUP attribute? I think so. Because we can still do inner queries with CFLOOP...and In my case this works. But I just need the grouping you see. So the problem is not so much the nested queries, but more the nested CFOUTPUTS of different queries.

    Thanks.
    Mikey.
    Inspiring
    December 22, 2008
    quote:

    Originally posted by: Kapitaine
    Hi Dan, that UNION sounds like a good idea for a situation like this, but in my particular instance it's just not possible. I'm curious though, how would grouping work with a UNION query? Is it any different?


    First you say it's not possible, then you ask how it works. H'mmmm.