Can anybody tell me if a sort of GROUP BY is supported by the <mm:list> tag in the 1.8 release of MMBase?

Regards, Ted

Michiel Meeuwissen wrote:

Ted Vinke <[EMAIL PROTECTED]> wrote:

All,
I've got forums, topics and messages related with eachother and now I'm
trying to generate a forum-overview sorted by date of the most recent
message:
---------------------------------------------------------
forumname | topics | messages | modified
---------------------------------------------------------
General 5 2 27/04/2004
Misc 6 1 23/04/2004
Roughly I'm using the following construction:
<mm:list
path="forum,topic,message"
fields="forum.name,forum.subject,forum.number,message.date"
orderby="message.date"
directions="UP"
distinct="true"
>
This however will return a record for every message there is in a forum
causing e.g. the forum "General" to appear twice in the list, because
there are 2 messages inside (topics inside) that forum. It seems that the
only way to keep message in the path and get the results I want is to have
some sort of GROUP BY part which groups by forumname, but I haven't been
able to figure out how. The documentation speaks of distinct and
constraints etc., but can somebody tell me if I can use <mm:list> with a
GROUP BY part or do I have to use another construction?



A real group by is not supported by mmbase.

You could try something like the following:

<mm:listnodes type="forum">
   <tr>
   <td><mm:field name="name" /></td>
   <mm:relatednodescontainer type="topics" searchdirs="destination">
        <td><mm:size  /></td>
   </mm:relatendodescontainer>
   <mm:relatednodescontainer path="topics,message" 
searchdirs="destination,destination">
        <td><mm:size  /></td>
        <mm:sortorder field="date" direction="down" />
        <mm:maxnumber value="1">
        <mm:relataednodescontainer>
           <td><mm:field name="date"><mm:time format=":FULL" /></mm:field></td>
         </mm:relatednodescontainer>
   </mm:relatednodescontainer>
</mm:listnodes>

Just a thought, heavily based on 1.7 features.


Michiel






Reply via email to