Table of Contents
- 1. Overview
- 2. To use Logic to include Articles
-
- 2.1.1. Examples using =
- 2.1.2. Examples using !=
- 2.1.3. Examples using CONTAINS
- 2.1.4. Examples using STARTSWITH
- 2.1.5. Examples using ENDSWITH
- 2.1.6. NOTE
-
- 3. Related
Overview
Use Template IF/THEN Logic to include content in your Templates and Articles.
To use Logic to include Articles
The conditional statement supports the following format:
%%if [VALUE1] [CONDITION] [VALUE2] then [ACTION] [VALUE3]%%
VALUE1, VALUE2 | String: "My string" Number: '12.33' Date: "12/12/2012" Set Variable: var Contact Data: first Custom Data: age |
CONDITION | =, !=, contains, startswith, endswith |
ACTION | print, printdata, includearticle |
VALUE3 | String: "My string" Number: '12.33' Date: "12/12/2012" Set Variable: var Contact Data: first Custom Data: age Article Name: "My Article" |
Examples using =
Print a string if the Contact first name is blank:
- %%if first = "" then print "Customer"%%
Display the Article if the variable is equal to YES:
- %%if display = "YES" then includearticle "MyArticle"%%
Examples using !=
Print the Contact birthdate if it is not blank:
- %%if birthdate != "" then printdata birthdate%%
Examples using CONTAINS
Print a string if the Contact state name contains WA:
- %%if state contains "WA" then print "Washington"%%
Display the Article if the Contact preference contains blue:
- %%if preference contains "blue" then includearticle "MyArticle"%%
Examples using STARTSWITH
Print the Contact storename if it starts with the character T:
- %%if storename startswith "T" then printdata storename%%
Examples using ENDSWITH
Print the Contact dinosaur if it ends with "rex":
- %%if dinosaur endswith "rex" then printdata dinosaur%%
NOTE
It is very important to maintain the spacing around [VALUE1] [CONDITION] [VALUE2]. If those items are in a logic statement without being separated by a space, the logic will not function.
For example, the following is correct:
%%if first = "" then print "Customer"%%
The following is NOT correct and will not function:
%%if first="" then print "Customer"%%