Loading the support system
Dynamic content in mailings is controlled by IF ... ELSEIF ... ELSE ... END IF
condition sets that are evaluated against mailing list columns to select specific content. Each condition within the set is defined by {{%
and }}
and is immediately followed by the statement body.
E.g.
Hello {{% IF state = 'IL'}}Illinois{{% ELSE }}other state{{% END IF }}
In the example above, if the recipient's state value is IL
, "Illinois" will be placed in the mailing content. In all other cases "other state" appears in the mailing content.
Condition sets are started with {{% IF [statement]}}
and finished with {{% END IF}}
. If either of those anchors are missing the condition set will not be extracted from the content for evaluation.
ELSE IF
conditions but only one IF
. IF
conditions found after the first position in the set will be converted to ELSE IF
.ELSE
. Evaluations that match no conditions will return an empty string.A full condition consists of the formatted condition, plus a statement, and statement body.
+---------------------- Statement --------------------+ | | Boundary Condition Type Statement Column Statement Operator Statement Value Boundary Statement Body | | | | | | | | +------------+ | | | +----------+ | | | | | | | | +-------------------- {{% IF state EQUALS 'IL' }}Illinois ---------------+
Valid condition types are
IF
,ELSEIF
, andELSE
IF
and ELSEIF
conditions must include a statement to evaluate. Statements consist of a column (equivalent to a mailing list column), an operator, and a comparison value.
Supported operators are
EQUALS
,IN
,GREATERTHAN
,GREATERTHANOREQUALS
,LESSTHAN
, andLESSTHANOREQUALS
Some operators can be aliased as described in the following table.
Operator | Supported Aliases |
---|---|
EQUALS | EQ, IS, =, == |
GREATERTHAN | GREATER_THAN, GT, > |
GREATERTHANOREQUALS | GREATER_THAN_OR_EQUALS, GTE, >= |
LESSTHAN | LESS_THAN, LT, < |
LESSTHANOREQUALS | LESS_THAN_OR_EQUALS, LTE, <= |
The statement value will be evaluated against the recipient list column value. It can be an integer or a string.
The condition set parser attempts to be as generous as possible and will record errors rather that invalidate a whole condition set. Parsed conditions are subject to secondary validation during the evaluation process. Conditions that fail parsing are omitted from the condition set and are stored as error results.
{{%IFstate='IL'}}
is as valid as {{% IF state = 'IL'}}
{{%ifstate='IL'}}
and {{%if state = 'IL'}}
will be errors.IL
, 'IL'
, and "IL"
are all equivalent as are 1
, '1'
, and "1"
. The evaluation code handles type conversion.my value
and 'my value'
are both valid.IN
operator, the statement value should be an array. E.g. [IL, WI, MI, MN]
. As with the other statement values, quoting the values in the array is not required.During the replacement context building process, conditions in the set are validated and may be marked as invalid. The validation matrix is described in the following table.
Condition | Column Required | Column Exists | Operator Required | Value Required |
---|---|---|---|---|
IF | Y | Y | Y | Y |
ELSE | N | N | N | N |
ELSEIF | Y | Y | Y | Y |
When condition sets use a first past the post evaluation process. I.e. the first match returns the replacement content,
E.g.
{{% IF city = 'CHI'}}The Windy City{{% ELSE IF city = 'CHI'}}Chi-town{{% ELSE IF city = 'NY'}}The Big Apple{{% END IF}}
In the above example, recipients with a city matching 'CHI' would get 'The Windy City' in the content.
If there is no match in a condition set and the ELSE
condition is not defined, an empty string will be inserted.