OpenWGA 7.6 - WebTML reference

WebTML tags » foreach

<tml:foreach sortexpression ="expression">


Sorts the iteration output by the results of an expression


Use this attribute together with attribute sortorder. It receives a TMLScript expression which is evaluated against every object to iterate over. The result of the evaluation is used to sort the iteration objects. They are sorted in the natural order of their expression results.

If the iteration uses a content documents (either type="content" or type="itemvalue" where the item list contains content documents) then the expression is executed in the context of that content document.

Other objects that are iterated are passed into the expression as WebTML variabie "$VALUE", also optionally under the variable name determined by attribute currentvalue.

For a more flexible, yet more complex approach, capable of performing sort using multiple sort criteria, use attribute sortcomparison.

Sorting can have very bad performance on large collections, even if only a small part of that collection is displayed. The reason for this is that OpenWGA needs to load all documents in the collection before it can sort them and determine what documents are in the requested page.

On collections from queries please consider using the query languages own ordering capabilities instead if possible.

On navigators please consider using attribute order instead if possible.


The sorting expression



    <tml:query> ... </tml:query>
    <tml:foreach sortorder="ascending" sortexpression="TITLE">
      <li><tml:meta name="title"/></li>

Displays a collection sorted in  ascending order of its document title.