OpenWGA 7.10 - TMLScript reference

CollectionResult
Method :

groupMap(function [,descending])

On object CollectionResult
Usage This method creates and returns a sorted map keyed by the return value of a user defined function where its value is a list of TMLContext objects evaluating to the same key.
Description

The function is called for each result entry with the TMLContext as parameter and must return some object usable as key (typically a string value or number).

If the return value of the function is null, the entry is ignored and not contained in the resulting map. This feature can be used to filter entries.

Parameters

function (Function):

A JavaScript function

decending (boolean, optiona, default=falsel)

retrieve a reversed ordered entry set

Return value Sorted map keyed  by the return value of a user defined function
Allowed in script types
  • WebTML pages and normal WebTML actions
  • Master actions
  • TMLScript tasks in jobs
  • Content type events
Examples
<tml:script>
   _map = WGA.nav("name:home").children().groupMap(function(doc){
      return doc.MODIFIED.year + 1900
   }, true)
</tml:script>
<tml:foreach item="_map" currentvalue="_entry">
   <h2><tml:item name="_entry.key" format="0"/></h2>
   <tml:foreach item="_entry.value" wrap="ul">
      <li><tml:meta name="title"/></li>
   </tml:foreach>
</tml:foreach>