Rules (checking content)
Table of contents |
FirstSpirit template developers can use rules (so-called “Dynamic forms”) to support and guide editors when they are entering editorial content. Editors can be made aware of invalid entries, for example.
Rules are defined on the “Rules” tab of a template. Defining rules is optional.
The following rules can be defined for CXT projects:
Which input needs to be checked?
The <PROPERTY/> tag is used to define which input needs to be checked. The required input component of the form is referenced using the source attribute.
The name attribute can be used to transfer the following property values:
- EMPTY: Checks if an input component has been filled with content (“mandatory field”)
- SIZE: Restricts the number of elements that can be selected (media or fragments, see also the “Using media” page, Restricting the number of media that can be selected section)
Example:
...
<WITH>
<NOT>
<PROPERTY name="EMPTY" source="title"/>
</NOT>
</WITH>
...
Complete syntax: See the example code below.
Determining the restriction level
Template developers can use the <VALIDATION/> tag in conjunction with the scope attribute for the EMPTY property to control the extent to which intervention into the editorial process is permitted.
- INFO: General control of the editorial process
Messages can be displayed to inform the editor of an invalid input, e.g., “An image caption helps with reading content aloud.” The release workflow can be started (thereby releasing the variant) even if an input is invalid.
This is the default value. - RELEASE: Prevents release if inputs are invalid
When the release workflow is started, a corresponding message is displayed to inform the editor of an invalid input. The workflow then cannot be started and the variant cannot be released.
The <MESSAGE/> tag is used to define the text of the message (see below).
The SIZE property is checked directly in the selection dialog: only the number of elements defined with the property SIZE for the corresponding input component can be selected.
Example:
...
<VALIDATION scope="RELEASE">
...
</VALIDATION>
...
Complete syntax: See the example code below.
Defining message text
Message texts that are to be displayed when an editor makes an invalid entry for a particular fragment can be defined by the project developer with the <MESSAGE/> tag, specifically in the <VALIDATION/> tag.
- text attribute: Specification of the (language-dependent) message text
- lang attribute: Specification of the language code that is to apply for the message text. Alternatively, * can be used for fallback values.
Example:
...
<VALIDATION ...>
<PROPERTY name="VALID" source="title"/>
<MESSAGE lang="*" text="Please enter a text"/>
<MESSAGE lang="DE" text="Bitte geben Sie einen Text ein"/>
</VALIDATION>
...
Combinations
Multiple conditions can be linked with the
- <AND/>
- <OR/>
- <NOT/>
tags.
Display for the editor
A variant can only be saved or released in FragmentCreator subject to compliance with the rule.
- In the editing area (section in the center of the screen), validation problems are visualized by means of text messages for the corresponding input elements.
- The status display (top right) lists the affected variants and input components.
A workflow cannot be started or advanced for a workflow that is affected by validation problems. A corresponding error message is displayed when the user clicks on an action button.
Conversely, the SIZE property is checked directly in the selection dialog, where only the number of elements defined for the corresponding input component with the SIZE property can be selected.
Example code
The example code below displays the text “Please enter a text here” at the input component in the form with the text identifier if the component has not been filled with content. Workflow actions are displayed inactive, the release workflow cannot be started, and the variant cannot be released:
<RULES>
<RULE>
<WITH>
<NOT>
<PROPERTY name="EMPTY" source="text"/>
</NOT>
</WITH>
<DO>
<VALIDATION scope="RELEASE">
<PROPERTY name="VALID" source="text"/>
<MESSAGE lang="*" text="Please enter a text"/>
<MESSAGE lang="DE" text="Bitte geben Sie einen Text ein"/>
</VALIDATION>
</DO>
</RULE>
<RULE>
<WITH>
<NOT>
<PROPERTY name="EMPTY" source="picture"/>
</NOT>
</WITH>
<DO>
<VALIDATION scope="RELEASE">
<PROPERTY name="VALID" source="picture"/>
<MESSAGE lang="*" text="Please select an image"/>
<MESSAGE lang="DE" text="Bitte Bild auswählen"/>
</VALIDATION>
</DO>
</RULE>
<RULE>
<WITH>
<NOT>
<GREATER_THAN>
<PROPERTY name="SIZE" source="picture"/>
<NUMBER>1</NUMBER>
</GREATER_THAN>
</NOT>
</WITH>
<DO>
<VALIDATION scope="INFO">
<PROPERTY name="VALID" source="picture"/>
<MESSAGE lang="*" text="Only one picture can be selected!"/>
<MESSAGE lang="DE" text="Es darf nur ein Bild ausgewählt werden!"/>
</VALIDATION>
</DO>
</RULE>
</RULES>
If the text input component is filled with content, the variant can be released.
On the basis of the definition, exactly one image must be selected for the picture input component, otherwise the variant cannot be released.
For general information about defining rules, see also Rules (→FirstSpirit Online Documentation).