Overview
Conditional Output allows parts of content to be included in Generated Content and Terms based on a specific condition.
For example, you might want to:
- Only output a paragraph of text if a Keyword Term has a value,
- Output a heading if a Keyword Term contains a specific value.
Syntax
In any content based Content Group field, the following syntax can be used for Conditional Output:
@if(condition) Conditional Output Here @endif
@if
and end with @endif
. If either are missing, Conditional Output will fail.Extending this syntax, an optional else clause can be added:
@if(condition) Conditional Output Here when condition passes @else Conditional Output Here when condition fails @endif
Syntax can be placed on a single line if necessary (bolding to show syntax only):
@if(condition) Conditional Output Here when condition passes @else Conditional Output Here when condition fails @endif
Conditions
The following conditions are supported:
Condition | Comparison Operator | Syntax |
---|---|---|
Has Value | (none) | @if({keyword})…@endif |
Equals | == | @if({keyword} == value)…@endif |
Does Not Equal | != | @if({keyword} != value)…@endif |
Greater Than | > | @if({keyword} > value)…@endif |
Greater Than or Equal To | >= | @if({keyword} >= value)…@endif |
Less Than | < | @if({keyword} < value)…@endif |
Less Than or Equal To | <= | @if({keyword} <= value)…@endif |
Contains | LIKE | @if({keyword} LIKE value)…@endif |
Does Not Contain | NOT LIKE | @if({keyword} NOT LIKE value)…@endif |
Examples
Output if Keyword contains a value
To only output some text when the Keyword {service} contains a value
@if({service}) Conditional Output about {service} would be displayed here. @endif
Output if Keyword matches a specific value
For example, to only output some text when the Keyword {service} matches the value Web Design
@if({service} == Web Design) Conditional Output about Web Design would be displayed here. @endif
Output based on Keyword containing a value, with a fallback if no value exists
For example, to output based on whether the Keyword {description} has a value or not
@if({description}) {description} @else A generic description to display when the Description keyword does not have a value @endif
Output if Keyword partially matches a specific value
For example, to only output some text when the Keyword {service} partially matches the value Web
@if({service} LIKE Web) Conditional Output about Web services would be displayed here. @endif