Documentation >> Conditionals >> Conditional Macros 101
Conditional Macros 101
Three Points
First, conditional macros are quite flexible. What you need in order to start using them, though, is a list of the macros that are allowed, and what operators can be used with each.
Second, you need to understand the syntax. We've tried to make this as flexible as possible, allowing AND and OR to be used, along with parentheses, but those are only needed for complex conditionals on advanced sites. We'll examine complex conditionals separately.
Third, remember that if you're using a conditional with an operator (some conditionals don't have operators), the conditional must be on the left, the operator in the middle, and some value on the right. Like this:
conditional operator value
Conditionals
There is a specific set of conditionals that can be used on the left. Each of these conditionals works with at least one operator. The documentation for each conditional specifies which operators are supported by that conditional.
Operators
The standard operators are == (equal to), != (not equal to), and nil (which means no operator, and thus no value to compare it with). There are a number of others, but none are being used in this first crop of conditionals , so I won't confuse you by mentioning them.
Operator |
Description |
|
No operator. Not all conditionals work without an operator. |
== |
Equal to. The two values are the same. |
!= |
Not Equal To. The two values are not the same. |
> or LessThan |
The first value is greater than the second value. |
>= or LessThanOrEqualTo |
The first value is either greater than the second value, or equal to the second value. |
< or LessThan |
The first value is less than the second value. |
<= or LessThanOrEqualTo |
The first value is either less than the second valud, or equal to the second value. |
BeginsWith |
The first value begins with the characters in the second value. Works only with text comparisons. |
EndsWith |
The first value ends with the characters in the second value. Works only with text comparisons. |
Contains |
The first value contains the full text of the second value. Works only with text comparisons. |
Values
The value to the right of the operator can be either an operatorless conditional (in programmer speak, we'll call that a unary condtional), or any text enclosed in single quotes.
Examples
Unary Conditional: a conditional that requires no operator.
<!--#if condition="userIsMember "-->
Conditional with Quoted Value: the value is static, same each time it's run
<!--#if condition="username == '[email protected]'"-->
Conditional with Unquoted Value: the value is dynamic, it's something that Conversant will evaluate before comparing it with the conditional
<!--#if condition="conditional_a != variable_value_b"-->
View in DG
|