OpenWGA 7.5 - WebTML reference
WebTML tags<tml:foreach>
Description :For all iterations. The body of this tag gets displayed for every iteration.
By specifying attribute "type" you determine what you want to iterate over:
- type="content" iterates over content documents from a variety of sources
- type="itemvalue" iterates over the values stored in an item or WebTML variable
- type="loop" iterates simply a given number of times
See the documentation of these types for a proper description.
Using sortorder and other sort... attributes the <tml:foreach> tag can sort the iterating values. Note however that WebTML needs to retrieve the whole result set for sorting, no matter how much results are actually shown, so this may be slow with large result sets. If the results originate from a query it is often very much better to use sorting functionalities of the query language used.
When the output of <tml:foreach> is redirected into some kind of WebTML variable - using attributes like var, sessionvar etc, - then the value is stored as a List containing each iterations result as element. However to retrieve the list in TMLScript you need to use this.itemList() for this.item() will only return the first element.
show inherited attributes ... | |||
Name | Value(s) | Purpose | |
count | 1...n | Specifies on type="loop" the number of iterations | |
currentvalue | variable | For type="itemvalue", type="loop" und type="tagresult" the current values of the iteration were written to the specified variable. | |
expression | TMLScript-expression | Executes a TMLScript expression whose result is used as iteration item | |
filllastpage | true | false | t | f | 1 | 0 | Controls, if the last page of a foreach-loop will be filled up with the last documents of the previous page, if the remaining documents are fewer than the pagesize. This only effects foreach loops with set pagesize. Defaults to "true". | |
filter | tmlscript-expression | Specifies a TMLScript expression to filter values or documents that are iterated | |
item | item | variable | Specifies on type="itemvalue" the name of an item whose values is to iterate over | |
linear | true | false | Enables "linear fetching", providing a more linear paging behaviour when invisible documents are involved | |
offset | 1..n | Specifies an offset from which the foreach tag should start iteration and paging computation | |
onlypublished | true | false |
Specifies if only published documents should be considered in the iteration. |
|
page | 1..n | Explicitly select the page to display on a paged output | |
pagesize | 1...n |
Dividing up the output into separate pages, each holding the number of results specified |
|
sortcomparison | tmlscript-expression | Determines an expression to compare iteration objects for sorting | |
sortexpression | expression | Sorts the iteration output by the results of an expression | |
sortitem | item | variable | Sorts the iteration output by a content item | |
sortmeta | meta-field | Sorts the iteration output by a metadata field | |
sortorder | ascending | descending | Determines a sort order for the iteration output | |
sourcetag | tag-id |
Specifies the id of source tag for a iteration over content documents if type="content". |
|
type="content" | content |
Iterates over content documents |
|
type="itemvalue" | itemvalue |
Iterates over the values stored in an item or WebTML variable |
|
type="loop" | loop |
Iterates a given number of times |
Tag-Infos :
pages:Total number of all representable pages.
currentvalue: The current value of the iteration(in detail at type="itemvalue|tagresult|level" the current item value/value in result tag/level).
haspreviouspage: Boolean-object, to indicate if a previous page exists (not made for direct use - use <tml:if haspreviouspage ...>).
hasnextpage: Boolean-objekt, to indicate if a next page exists(not made for direct use - use <tml:if hasnextapge ...>).
startindex: Index of the first value of the current displayed page.
endindex: Index of the last value of the current displayed page.
count: Total number of representable values.
iteration: The current number of iteration.
See documentation about values of the type attribute for examples how to use them: