move context into each element of a group |
|
| see each, group | |
grouping nodes
The group method takes a list as input and groups items using the given attribute. The object available in “each_group” is the first element of the list of grouped items.
<ul do='nodes in project order by parent_id asc' do='group' by='parent_id'> <li do='each_group'><h3 do='parent.title'/> <ul> <li do='each' do='link'/> </ul> </li> </ul>
You can use the method to group other elements such as data or comments:
grouping comments
<ul do='comments from nodes in project order by created_at desc limit 20' do='group' by='discussion_id'> <!-- comments grouped by node --> <li do='each_group'><h3 do='node.title'/> <ul> <!-- shows a single comment --> <li do='each' do='title'/> </ul> </li> </ul>
grouping data
<r:data> <r:group by='node_a'> <r:each_group><r:stat find='sum'/> <r:each>...</r:each> </r:each_group> </r:group> </r:data>