Dynamic Code Tags

This topic provides examples of tags that you can use for dynamic code.

You must put your dynamic code between {dynamic_code} tags.

Syntax:

{dynamic_code}
	{<dynamic tag> <your dynamic code>}
	{/<close dynamic tag>}
{/dynamic_code}
Tag Example
{if}
{if $Contact.firstname eq "Joe"}
{/if}

It is the only operator allowed as the first element of a block and can contain additional operators and comparison expressions.

{elseif}
{if $Contact.in_list."Customer List" eq true}
{elseif $Contact.in_list."Client List" eq true}
{/if} 

It cannot appear after the {else} conditional. It can contain additional operators and comparison expressions. The {elseif} conditional does not require a closing tag.

{else}
{if $Contact.in_list."Customer List" eq true} Joe
{else} John
{/if}

The {else} conditional is a child of, and the last tag added within the {if} conditional.

It does not contain additional operators and comparison expressions. The {else} conditional does not require a closing tag.

{literal}
{dynamic_code}
	{if "%%$cart.status%%" eq "ABANDONED"}
		{literal}This is content using {curly_braces}. 
		These curly braces will not be interpreted as Dynamic Code because they are contained within literal tags{/literal}
	{/if}
{/dynamic_code}

In the code example above, the curly braces contained in the literal tags will be output verbatim and will be ignored by the Dynamic Code processor.

Literal tags are placed around content that is displayed to your contacts when the Dynamic Code conditions are met. These tags will display the literal content within them, including anything in curly braces that might otherwise be interpreted as Dynamic Code.

Note: If you choose not to use literal tags, then you can add nested logic to your Dynamic Code. In the absence of literal tags, dynamic code (actually anything in curly braces) will be treated as if it is Dynamic Code. Hence, if you try and use curly braces outside of literal tags, and the curly braces are not part of valid Dynamic Code syntax, you will receive an error.
{loop}
{dynamic_code}
	{loop}
		%%#item_#%%
	{/loop}
{/dynamic_code}

Loop tags are specially formatted API message tags that allow content to be passed in via API Message tags as an array. This an especially useful feature to use with transactional email messages.

For more information about loop tags see API Loop Tags.

{cart_loop}
{dynamic_code}{cart_loop}
	<tr>
		<td>%%$cart.item.name%%</td>
		<td>%%$cart.item.category%%</td>
		<td>%%$cart.item.description%%</td>
		<td>%%$cart.item.other%%</td>
		<td>%%$cart.item.sku%%</td>
		<td>%%$cart.item.unitprice%%</td>
		<td>%%$cart.item.saleprice%%</td>
		<td>%%$cart.item.quantity%%</td>
		<td>%%$cart.item.producturl%%</td>
	</tr>
{/cart_loop}{/dynamic_code}

The {cart_loop} tag allows you to read through the array of line items associated with a shopping cart or an order, and dynamically insert that data into an email message. The message can then be sent via a workflow using the Cart Is Abandoned trigger node.

For more information about cart loops see Cart Loop Tags.

API Loop

{dynamic_code}
	{loop}
		{if "%%#product_id_#%%" eq "12345"}
		{literal}SHIPPING DETAIL{/literal}
		{else}
		{literal}SHIPPING DETAILS{/literal}
		{/if}
		{/loop}
		{/dynamic_code}

API loop tags are specially formatted API message tags that allow content to be passed in via API Message tags as an array. This an especially useful feature to use with transactional email messages.

For more information see API Loop Tags.