Dynamic Template Language In Emails

21 August, 2020

Introduction

Dynamic content is an exciting new functionality that enables powerful content customization. With dynamic content, you can send an email or generate a PDF document (requires optional PDF Add-On) with HTML formatted text displayed based on the field values.

For example, you can structure the Subject of your emails to display the appropriate user name, rather than hard-coding a particular value:

Thanks {{name}}. We have received your message.

Currently, this functionality is available in:

  • Confirmation Messages
  • Confirmation Emails and
  • Email Notifications

Also, Dynamic Content is available in our Premium Add-Ons like Conditional Emails or PDF.

Variables

You can insert variables into the email body, and they'll be replaced with whatever the user insert into that field.

To print a variable, it must be between double curly braces: {{ and }}. Eg. {{ My Variable }}

In the following example, we show two ways you can print variables:

  • By using the Field Label: The variable {{ Your Name }} has been inserted to the confirmation email and will be replaced by the name the user puts in the Form.
  • By using the Field ID: You can use a Field ID as the variable name too, for example in the next image we use the following variable to print the Name of the user: {{ text_1 }} at the same time we use {{ Your Name }}. In other words, we can use both types of variables to get the same field information. If your field doesn't have a label, this is the option you should use.

 

Additionally, you can use the following variables:

  • {{ form_id }}: Form ID.
  • {{ form_name }}: Form Name
  • {{ submission_id }}: Submission ID
  • {{ submission_number }}: Submission Number
  • {{ submission_table }}: The content of all the form fields
  • {{ created_at }}: Date of Submission
  • {{ ip_address }}: IP Address.
  • {{ user_agent }}: Browser’s User Agent of Sender.
  • {{ url }}: Web page url where form has been embedded.
  • {{ referrer }}: Web page url from where the visitor has arrived to the form.
  • {{ country }}: Country of Sender.
  • {{ city }}: City of Sender.
  • {{ longitude }}: The geographic coordinate that specifies the east-west position of Sender.
  • {{ latitude }}: The geographic coordinate that specifies the north–south position of Sender.
  • {{ edit_link }}: To display the url to the Public Form Page to Edit a Submission. You should enable "Save to DB" & "Editable" to use this feature.
  • {{ optin_link }}: To present the link to the Opt-In Confirmation Page. You should enable "Save to DB" to use this feature.

This is a great way to personalize your message. Any form field can be used in this way.

Auto-Suggest Tool

"Form Settings", "Form Rules" and Premium Add-Ons allow the replacement of placeholders by data collected by your forms. To make things easier, we have implemented a visual tool that allows you to select form fields without remember them. To use this tool just enter a curly bracket "{", and the list of Form Fields will appear, select the desired field and ready.

Filters

Filters allow change the output of a variable. It must be used after the variable and separated by a pipe "|".

Use Default Values

For non-required fields, you can specify a default value to be used if it doesn't have any value.

Thanks {{ Name | default: 'friend' }}, we have received your message!

For a user named John, this would read “Thanks John, we have received your message!”. However, if a submission didn't have a name, it would read “Thanks friend, we have received your message!”

Change Date Formats

Converts a timestamp into another date format.

{{ created_at | date: "%a, %b %d, %y" }}

Output: Fri, Jul 17, 15

{{ created_at | date: "%Y" }}

Output: 2015

Conditionals

You can use conditional logic into your content. You may want to send the same email with differences for different groups. The most common use-case for this is language localization, where you want to send different content to different users.

Use Multiple Languages

In the example below, if a user named John selects his preferred language as Spanish, he will see their message as “Hola, John!”

{% if Language == 'Spanish' %}
  Hola {{ Name }}! 
{% elseif Language == 'French' %}
  Bonjour {{ Name }}!
{% else %}
  Hello {{ Name }}!
{% endif %}

Show Images

Another common use case is display multiple images uploaded by a same file field in different places. For that, you can do the following:

{% if file_1[0] %}
First Image

{{% endif %}}

{% if file_1[1] %}
Second Image

{{% endif %}}

 

TDB Forms

16 The Maltings, Stanstead Abbotts Hertfordshire SG12 8UU UK
 webmaster@tdbforms.com

2024 TDB Computing. All rights reserved.  With grateful thanks to unsplash.com for the amazing photos.