2.8.3. Component tag reference

A component consists of several types of tags. Here we would like to describe them.

2.8.3.1. Defined component tag

A defined component tag (for example {selectComponent}) takes 0 or more parameters:

Table 2.16. Defined component tag: parameters

Defined component tag: parameters
NameTypeRequired?Description
datasourceExpressionNoA source for the component data.

Additional parameters represent unsually HTML tag parameters and depend on the component we use.

A component making use from the datasource parameter can read the data for example from an external array instead of using {listItem} tags.

Example 2.67. Datasource parameter

{selectComponent name="interests" datasource="$listItems"}
  {param name="selected" value="$selected"/}

  {onMessage message="msg" position="up"}
    <p>Error: {@msg}</p>
  {/onMessage}
{/selectComponent}

2.8.3.2. Undefined component tag

An undefined component tag takes at least one parameter:

Table 2.17. Unefined component tag: parameters

Unefined component tag: parameters
NameTypeRequired?Description
idExpressionYesA block that contains the exact component.
datasourceExpressionNoA source for the component data.

Additional parameters represent unsually HTML tag parameters and depend on the component we use.

2.8.3.3. {param} tag

The tag allows to set additional parameters for the component.

Table 2.18. Parameter tag: parameters

Parameter tag: parameters
NameTypeRequired?Description
nameExpressionYesThe name of the parameter we set.
valueExpressionYesThe value we want to assign.

For example, selectComponent uses it to get to know, which list element is selected.

2.8.3.4. {listItem} tag

If the component operates on lists, you may define static list items using this tag.

Table 2.19. Listitem tag: parameters

Listitem tag: parameters
NameTypeRequired?Description
nameExpressionYesThe name of the list item we set.
valueExpressionYesThe value we want to assign.
selectedExpressionNoIs this element selected by default? This setting may be overwritten by the selected parameter, if supported.

2.8.3.5. {load} tag

Sometimes you use the same event in many different places. You may write it only once and store it in the compiler memory under a specified ID using bindEvent instruction. This tag allows to load such shared events into the component.

Table 2.20. Event loader tag: parameters

Event loader tag: parameters
NameTypeRequired?Description
nameIdYesThe ID of a shared event.

Example 2.68. Loading shared events

{bindEvent id="messageEv" name="onMessage" message="msg" position="down"}
<p>Error: {@msg}</p>
{/bindEvent}
...
{selectComponent name="interests"}
   {load event="messageEv"/}
{/selectComponent}
...
{inputComponent name="age"}
   {load event="messageEv"/}
{/inputComponent}

This code could be also written as:

Example 2.69. No shared events

{selectComponent name="interests"}
   {onMessage message="msg" position="down"}
    <p>Error: {@msg}</p>
   {/onMessage}
{/selectComponent}
...
{inputComponent name="age"}
   {onMessage message="msg" position="down"}
    <p>Error: {@msg}</p>
   {/onMessage}
{/inputComponent}

However, as you see, it is less clear and harder to modify (especially if there is a large number of components and we want to make the events display above, not under the component). Note that you may put the shared events in the master template.

2.8.3.6. Event tags

All other tags defined inside the component are called event tags. An event is a piece of HTML that may be shown around the component, if some event occured (for example, the data are invalid). They are mostly used to display error messages, when the specified form data do not match to the patterns.

Table 2.21. Unefined component tag: parameters

Unefined component tag: parameters
NameTypeRequired?Description
nameIdYesThe name of an event (for example: "onmessage").
messageIdYesThe variable name the event passes the message to.
positionIdNoDisplay position of the event. Possible values: "up", "mid", "down".