OpenWGA 7.10 - OpenWGA Concepts and Features

Design and development » WebTML » Basic concepts

Document collections

Document collections are a WebTML facility to select a group of documents and put out some data about them. Mostly this data consists of HTML links for opening the document page in browser or show some actual item data inline on the page.

Document collections are mostly used to either build navigational link collections or to show the results of specific queries. Therefor there are two types of document collections, which we call navigators and queries. Both will be described in detail in the subchapters of this page.

Both collection types however use the same way to let you define the individual output per document. This way is based on the functionality of the WebTML tag <tml:foreach>. In short this tag goes through all documents of the collection and switches the document context to each single document. Then, for each document context the contents of the <tml:foreach> tag is rendered once. In other words: Whatever WebTML code you specify inside <tml:foreach> will be rendered and put out for each document of the collection.

You could simply generate a link for each single document in the collection which uses the document title as link text:

<tml:foreach>


  <a href="<tml:url/>"> <tml:meta name="title"/> </a> <br>


</tml:foreach>

The output may look like this if we had documents of title "Welcome to this site!", "About us" and "Contact" in the collection:

<a href="...url..."> Welcome to this site! </a> <br>

<a href="...url..."> About us </a> <br>

<a href="...url..."> Contact </a> <br>

This way you can produce any output per document that WebTML is capable of producing. You could show item data via <tml:item>, execute individual TMLScript functionalities via <tml:script>, you could even render other WebTML modules in the context of each collection document by performing a <tml:include> in the body of <tml:foreach>.

All document collections have sorting capabilities utilizing the <tml:foreach> attributes sortorder plus one of sortitem, sortmeta or sortexpression. The following example sorts the output documents by their title:

<tml:foreach sortorder="ascending" sortmeta="title">
....
</tml:foreach>

However sorting in WebTML is quite slow and resource intensive. You should do this only with small document collections. Queries provide better ways of sorting which are more effective.

Another functionality available for all document collections is paging. This divides up the selected documents into individual pages with the same number of documents. These collection pages then can be browsed using adequate URLs. Use attribute "pagesize" on <tml:foreach> to initiate paging and specify the number of documents you want to see on each page as attribute value. Then use <tml:url type="nextpage|previouspage|selectpage"> to create URLs navigating to individual collection pages. Reference the <tml:foreach> there by an individually determined tag ID.

The following example puts out 10 documents per page and creates browsing links to previous and next page:

<tml:foreach pagesize="10" id="mycollection">

   ... output code ...

</tml:foreach>


<a href="<tml:url type="previouspage" sourcetag="mycollection"/>">Previous page</a>


<a href="<tml:url type="nextpage" sourcetag="mycollection"/>">Previous page</a>

If you want to hide the page browsing links when there is no previous/next page you can use condition tags using conditions haspreviouspage and hasnextpage:

<tml:case haspreviouspage="mycollection">

  <a href="<tml:url type="previouspage" sourcetag="mycollection"/>">Previous page</a>

</tml:case>


<tml:case haspreviouspage="mycollection">

  <a href="<tml:url type="nextpage" sourcetag="mycollection"/>">Previous page</a>

</tml:case>

Lastly you can retrieve information about the currently shown collection page as taginfos of <tml:foreach> so you can display them. 

<tml:foreach pagesize="10" id="mycollection">

... output code ...

</tml:foreach>


Displaying page <tml:taginfo sourcetag="mycollection" name="currentpage"/> of <tml:taginfo sourcetag="mycollection" name="pages"/>

See documentation of <tml:foreach> for other available taginfo fields.

Table of contents: