Go to main content

If variable




The if_variable tag is a conditional tag and always used as an opening and closing pair, like this…

    …conditional statement…

It tests the existence and/or value of a global variable set with the variable tag.

Note: In case you are getting unexpected results in an if_variable evaluation, check whether you have entered additional white space or invisible characters in your variable declarations and remove those.


Tag will accept the following attributes (case-sensitive) as well as the global attributes :

match="match type" v4.8.0+
How you wish your value to be tested. Choose from:
exact: value text must exactly match the variable.
any: checks if any of the given comma-separated list of values occur anywhere in the variable.
all: checks if all of the given comma-separated list of values occur anywhere in the variable.
pattern: allows you to specify a regular expression in your value attribute to match against the variable.
Default: exact.
name="variable name"
The name of the variable you wish to check.
separator="character" v4.8.0+
If you wish to treat your variable as a list of items - so that each item is a discrete entity and tested separately when using any or all matching - specify the delimiter that you use in the variable. This attribute is ignored if using exact or pattern matching.
The (optional) value which the named variable must match in order for the contained statements to be executed. If this attribute is omitted, the tag returns ‘true’ if the named variable is defined. If this attribute’s value is omitted (i.e. value="), the tag returns ‘true’ if the variable is defined, but has no value.


See the variable tag page for examples.


Version 4.8.0

Added match and separator attributes.

Version 4.0.7

Tag support added.

If you notice any kind of problem with this page's construction or content (outdated information, typos, broken links, or whatever), open an issue to have it sorted. Or have a go at it yourself. :)