Start page / Template development / Rules / Handling instructions <DO/>

<DO/> Defining handling instructions

For each rule, a handling instruction must be defined that functions depending on the previously defined conditions or on the previously determined value. In the handling instruction, the template developer links the results from the value determination with certain actions in the form, such as the selection of an input component or the display of a correction note. In the process, the following is differentiated:

  • simple handling instructions that are executed as long as all previously defined conditions are fulfilled and
  • validations, whose handling instructions are performed as long as the previously defined conditions are not fulfilled. In contrast with the simple handling instruction, the handling instructions in a validation always refer to a certain input component of the form.

Handling instructions are defined within a <DO/> section. This section must be defined after the tags that initiate a value determination.

In the process, the following applies for the definition of a handling instruction:

  • For each rule, a handling instruction must be defined.
  • A handling instruction reacts to the result of the value determination. The instructions within the <DO/> section must match the transferred values from the <WITH/> section (see table).

Result of the value determination

Handling instructions <DO/>

Boolean value

Instructions within the <DO/> section are executed as long as the value determination is fulfilled (TRUE). If the condition is not fulfilled (FALSE), the handling instruction has the opposite effect. For example:

Value determination:
The value from component A is equal to the value from component B.
Handling instruction:
Display component C in the form.

Result:
TRUE (A == B) -> C is shown in the form
FALSE (A != B) -> C is hidden in the form

Any value (date, text, number of values)

Instructions are executed within the <DO/> section. The transferred value can continue to be used within the handling instruction, for example, to fill a second input component, for example:

Value determination:

Read and modify value from component A.
Handling instruction:
Assume the adapted value in component B.

Result:
The adapted value from component A is automatically assumed in component B.

  

If the result of the value determination is a Boolean value, a negation can be performed using the <NOT/> tag, in conjunction with

Examples

Example 1) Displaying or hiding areas of the form dependent on a condition

After the successful authentication, a protected area in the form should be displayed. The form initially shows the editor only a password entry field (st_passwort). When value is entered by the editor, the value entered there from the FirstSpirit framework is compared with the value within a hidden form field (st_master_passwort). if both values are identical, the condition defined within the value determination is fulfilled. The instructions defined within the handling instruction are thus executed. In the form, a component of type CMS_LABEL (st_secret) with the note “Authentication successful” and a component of the type CMS_GROUP (st_secret_group) with “protected content” are displayed. If the passwords are not identical, the second part of the rule definition that shows only the generally accessible content (st_public) comes into effect.

<RULES>

<!-- show secret area only when current password does match master password -->
<RULE>
<WITH>
<EQUAL>
<PROPERTY source="st_master_password" name="VALUE"/>
<PROPERTY source="st_password" name="VALUE"/>
</EQUAL>
</WITH>
<DO>
<PROPERTY source="#form.st_secret" name="VISIBLE"/>
<PROPERTY source="#form.st_secret_group" name="VISIBLE"/>
</DO>
</RULE>

<!-- show public area only when current password does not match master password -->
<RULE>
<WITH>
<NOT>
<EQUAL>
<PROPERTY source="st_master_password" name="VALUE"/>
<PROPERTY source="st_password" name="VALUE"/>
</EQUAL>
</NOT>
</WITH>
<DO>
<PROPERTY source="#form.st_public" name="VISIBLE"/>
</DO>
</RULE>

</RULES>

Example 2) Negation

Rules negation of boolean values

In this example, the template contains three text fields:

  • text field 1: “st_text_1”
  • text field 2: “st_text_2”
  • text field 3: “st_text_3”

Text field 1 is always displayed, text field 2 is displayed if text field 1 is empty, and text field 3 is displayed if text field 1 is not empty.

<RULES>
<RULE>
<WITH>
<PROPERTY name="EMPTY" source="st_text_1"/>
</WITH>
<DO>
<PROPERTY name="VISIBLE" source="st_text_2"/>
<NOT>
<PROPERTY name="VISIBLE" source="st_text_3"/>
</NOT>
</DO>
</RULE>
<RULES>

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.4 | Data privacy