How can we help?

Conditionals and Loops Overview

Smarty provides you a powerful way to pull data into a message and render it according to certain rules and filters. You are also able to update portions of your Cordial database using Smarty utilities. For a complete list of available utilities, see the Cordial utilities reference page.

In this section we'll cover the following techniques:

  • {if} statements - renders content based on a condition.
  • {foreach} statements - retrieves data arrays, loops through the items and executes a specified operation which may include printing data for each item in the message.
  • Randomizing content - randomizes what content will show in a message.
  • Calculate distance betweeen postal codes - calculates the distance between 2 postal codes, which is useful for sorting records by proximity. (Ex: printing the 5 nearest store locations for each contact.)
  • Sort an array - sorts an array of data according to a key in ascending or descending order.
  • String contains - finds a string of characters within another string.
  • Update contact attribute or list values - updates contact attributes and list values when a message is sent.
  • Send webhook - pings a URL at the time a message renders (preview or send).
  • Last send timestamp - renders the last send date of a specified automation template.
  • Add send properties - adds key/value pairs to the properties object of any system event related to the message contact ID (open, click, bounce, etc.).

Comments

0 comments

Please sign in to leave a comment.