Conditional display
Show a piece of text (separator, label…) only when certain variables are filled in.
Some elements only make sense when a piece of information exists. Example: the "|" separator between two phone numbers should only appear when the person has both numbers. Conditional display handles this without creating one template per combination.
The [if] syntax
Wrap the text to show conditionally between [if …] and [/if], listing the
variables that must be filled in:
{{user.phone_mobile}}[if {{user.phone_mobile}} {{user.groupauto.phone}}] | [/if]{{user.groupauto.phone}}The text between [if …] and [/if] is shown only when all the listed
variables are filled in. The [if] / [/if] markers themselves are never
displayed.
| Mobile | Group phone | Result |
|---|---|---|
| 06 12 34 56 78 | 01 23 45 67 89 | 06 12 34 56 78 | 01 23 45 67 89 |
| 06 12 34 56 78 | empty | 06 12 34 56 78 |
| empty | 01 23 45 67 89 | 01 23 45 67 89 |
| empty | empty | (nothing) |
Where to use it
- Email signatures: in Text and Rich text blocks, and in HTML mode.
- Profile pages: in the Text block.
Any variable, including group variables, can be used as a condition.
Rules
- Separate variables with a space:
[if {{user.email}} {{user.phone_mobile}}]. - A single variable is fine:
[if {{user.phone_mobile}}]Mobile: [/if]{{user.phone_mobile}}. - Blocks can be nested:
[if {{user.phone_mobile}}]M[if {{user.phone_office}}] / O[/if][/if]. - Case doesn't matter:
[IF …]works. - An unknown or misspelled variable counts as empty: the text is hidden.
Rich text and HTML: the data-ecard-if attribute
In the Rich text block and in HTML mode, you can also hide a whole
tag with the data-ecard-if attribute. The "Condition" button in the
Rich text toolbar adds it for you: select the text, click "Condition", pick the
variables, then "Apply".
<span data-ecard-if="{{user.phone_mobile}}{{user.groupauto.phone}}"> | </span>Same rule: the tag is shown only when all the variables are filled in.
Troubleshooting
[if …]shows as-is → the marker is malformed: check that it contains at least one{{…}}variable and is closed with[/if].- The text never shows → one of the variables is empty in the profile, or misspelled. Check the preview with a user whose information is complete.
- Outlook still shows the old version → save the signature again so the version served by the Outlook add-in is regenerated.