OpenWGA 7.6 - OpenWGA Concepts and Features

Design and development » WebTML » Features » Forms

Storing content relations

Content relations are a feature of the OpenWGA content store of version 5. They represent point-to-point relations between two content documents. A content relation is part of a content document just like an item, and like this it is addressed by a custom name and is saved when the content document is saved. But unlike an item a relation does not store actual data but merely points to another content document, the relation target. Content relations are therefor the ideal and most performant way to express relations between data.

By using attribute relationtype on tag <tml:input> the data of this input will no longer be stored on an item but rather a relation. This is only possible if the form data will get stored on a content document, as this is the only document capable of storing content relations. The name of the input will then be used as the name of the relation to store. The contents of attribute "relationtype" determines the type of relation to create, either "protected" which prevents the target document from being deleted while the relation points to it or "normal" which does not offer this protection.

An input field which stores an relation will still be displayed as a normal HTML input. But this input of course can neither really display the target document of the relation, nor can it have the actual target document as a value.  Therefor the input really contains the struct key of the target document instead of the document itself. This in most cases is not entered manually by the user. Instead most times a choice of target documents is offered in an input of type="select|checkbox|radio" which is prepared by the design code. For this purpose take note the TMLScript method WGA.buildOptions() which is able to easily build preformatted option lists from lists of content documents. See the following example:

<tml:script>

targets = createList();

targets.add(context("name:home").content());

targets.add(context("name:help").content());

targets.add(context("name:sitemap").content());

</tml:script>


Start page: <tml:input name="startpage" relationtype="normal" options="{WGA.buildOptions(targets)}"/>

In the script block a small list of WGAPI content objects is created. This list is then used inside the "options" attribute of the input. There it is passed to the method "WGA.buildOptions()" which automatically creates an option list offering these documents as target of the relation to store.