OpenWGA 7.11 - WebTML reference

WebTML tags » foreach

<tml:foreach pagesize ="1...n">


Dividing up the output into separate pages, each holding the number of results specified


If you do not want do display all results of the tag on on page, you can divide up the output using this attribute. Specifying a pagesize of 10 will let only 10 results be displayed per page.

The <tml:foreach> tag offers some ways to change the page of the result that is currently displayed:

The tags (<tml:url>) types type="nextpage|previouspage|selectpage" allow you to generate links to other result pages. These URLs display the same WebTML page, but with the next(nextpage) or the previous(previouspage)  or a specified(selectpage) page of n results. Whether such pages exist can be checked with the conditions hasnextpage, haspreviouspage or with the tag-infos of <tml:foreach> which show you on which page you currently are and how many there are in total.

Another way is to use the attribute page on <tml:foreach> to explicitly choose the number of the page to be displayed. You can calculate this attribute value by any mechanism that you need to implement the wanted paging behaviour. The value 1 represents the first page, the value 2 the second, and so on ...

Yet another way is to control the displayed page by setting the internal WebTML-variable "$idPage". $id should be replaced by the id of your foreach tag.This variable sets the currently displayed page of your tag. It should be set before the <tml:foreach> tag is evaluated.


A positive value to enable paging. 0 to disable it and show all results on one page.


The following <tml:foreach> tag displays a result of a lucene search in pages of 5 results: 

    <tml:query cache="false" type="lucene" includecurrent="true"><tml:item type="tmlform" name="query"/></tml:query>
    <table width="100%">
        <tml:foreach id="hotpages" pagesize="5">
                <td><tml:meta name="doctype"/></td>
                <td><tml:meta name="created"/></td>

The following codes displays URLs to scroll over the result pages.Also it displays which documents of the result set are currently displayed:

<table width="100%" border=0> 
        <td align="left">
            <tml:case haspreviouspage="hotpages">
                <a href="<tml:url type="previousPage" sourcetag="hotpages" form="search"/>">Previous page</a>
        <td align="center">
                    Document <tml:taginfo sourcetag="hotpages" name="startindex"/> to <tml:taginfo sourcetag="hotpages" name="endindex"/> from <tml:taginfo sourcetag="hotpages" name="count"/>.
        <td align="right">
        <tml:case hasnextpage="hotpages">
            <a href="<tml:url type="nextPage" sourcetag="hotpages" form="search"/>">Next page</a>