Start page / Template development / Rules / Structure of a rule

Creating rules: the structure of a rule

Each rule definition consists of the follow subcategories:

Rules creation (scheme)Tag <DO>Tag <WITH>Tag <RULE>Tag <VALIDATION>Execution time (attribute "when")Tag <DO>Tag <RULE>Restriction levels (scope="SAVE || RELEASE || INFO")Tag <VALIDATION>Tag <IF>

1. Define the execution time for the rule

Within a rule definition (<RULES>...</RULES>), several independent rules can be defined for a form. Each rule must be enclosed within an opening and closing <RULE>tag and must always contain at least one value determination (3.) and one handling (4.) instruction.

By default, a rule defined inside a <RULE/> tag is executed immediately when a form is edited, i.e., (depending the component type) whenever characters are entered (e.g., CMS_INPUT_TEXT, CMS_INPUT_DOM), a value is selected (e.g., CMS_INPUT_CHECKBOX, CMS_INPUT_DATE), or a reference is selected (e.g., FS_REFERENCE, FS_DATASET).

The optional attribute “when” is used to define that the rule must only be executed once

  • During saving (ONSAVE) or
  • When editing mode is started or when pages, sections, or datasets, for example, are created for the first time (ONLOCK)

2. Define precondition (optional)

In a rule definition, a precondition can be defined within an <<IF/> section. A precondition always refers to a certain property of the form element or form (e.g., “was the form opened in the Content Store?”). The subsequent sections of the rule definition are performed only if the precondition is fulfilled (and this section of the rule definition returns TRUE).

A precondition always refers to a certain property of the form element or form. The corresponding information is contained within a PROPERTY tag. Comparisons and links are possible with special tags.

For more information, see Defining preconditions for rule execution.

3. Value determination

A rule always checks one or more properties of the form (“in which editorial language is the form edited?”) or an individual form element (“is the value of the component "NULL" (ZERO)?”). The desired properties are taken into consideration in the value determination of the rule definition.

In the simplest case, the check can be made against a constant (<TRUE/>, <FALSE/>, <TEXT/>, <NUMBER/>) or it can reference values or properties of the form or a form element. The corresponding information is contained within a PROPERTY tag. Comparisons and links are possible with special tags.

The value determination can take place:

  • Synchronously within a <<WITH/>/> tag or
  • Asynchronously within a <SCHEDULE/> tag

The determined result is then evaluated within the handling instruction (4.).

For more information, see Value determination (<WITH/>) or Asynchronous rule execution (<SCHEDULE/>).

4. Defining a handling instruction

For each rule, a handling instruction must be defined that functions depending on the previously defined conditions (within the value determination). 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. Handling instructions are defined within a <DO/> section.

A distinction is made between

  • Simple handling instructions that are executed as long as all previously defined conditions are fulfilled
  • Validations (5.), 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. The corresponding information is contained within a PROPERTY tag.

Comparisons and links are possible with special tags.

For more information, see Defining handling instructions.

5. Validation (optional)

A validation is a certain handling instruction that is performed as long as the conditions defined within the <WITH/> section are not fulfilled (i.e., as long as the value determination returns FALSE). A validation is defined within a <VALIDATION/> section in the <DO/> area of a rule and must always be assigned to a certain input component within the form. An internal <PROPERTY/> tag is thus defined within the validation with the name of an input component and the attribute VALID.

For more information, see Validating input components.

5a. Determining the restriction level

If a validation has been defined for a rule (5.), the editorial process can be controlled and saving or releasing an incorrect input can be prevented, for example. There are three levels

The selection of the restriction level affects how the rule violation is displayed as well as save and release operations in SiteArchitect or ContentCreator, if applicable.

If a restriction level is not defined, INFO is used automatically.

For more information, see Controlling editorial processes (restriction levels).

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