# Dynamic Content Syntax

<article class="article-body" id="bkmrk-prerequisite%C2%A0%3A%C2%A0dynam">**PREREQUISITE** : [Dynamic Content](http://inboxmarketer.freshdesk.com/support/solutions/articles/19000043116-how-to-provide-targeted-information-using-dynamic-content)

Allows the user to create dynamic content statements without needing to know the syntax.

A new syntax has been created in the system which allows developers to keep all content and logic within one document.

---

## Syntax

- \##FirstName##
- \##FirstName Format="Firstlettercapital"##
- \##FirstName Default="Customer"##
- \##FirstName Format="Firstlettercapital" Default="Customer"##

---

## Data Types for Format

- Email : No formatting options
- Text : ALLCAPS, lowercase, Firstlettercapital, EachWordFirstLetterCapital
- Number : WholeNumber, OneDecimal, TwoDecimal
- Date : MM/dd/yyyy, MM-dd-yyyy, MMMM dd, yyyy, MMM dd, yyyy

---

## Dynamic Content Syntax.

<div><div>HTML</div></div>```html
###variablename###
 if (field[FieldName] operator "value" ) { "Content" }
else if (field[FieldName] operator "value" ) { "Content" }
 else { "Content" }
###/variablename###
```

---

## Logic Breakdown (Part 1)

<div><div>HTML</div></div>```html
if (field[FieldName] operator "value" ) 
```

- FieldName has to match the one in CONNECT, Operators are different depending on the Field type (i.e. Email, Text, Date, Number)
- You can have as many else ifâ€™s as needed

---

## Logic Breakdown (Part 2)

### Email/Text Operators:

```text
equals, is_not, begins_with, contains, not_contain, is_empty, not_empty 
```

### Number/Date Operators:

<div><div>HTML</div></div>```html
==, !=, greater, greater_or_equal, less, less_or_equal, is_empty, not_empty 
```

### AND/OR Statements:

<div><div>HTML</div></div>```html
if ((field[ ] ) && (field[ ] )) 
```

<div><div>HTML</div></div>```html
if ((field[ ] ) || (field[ ] ))
```

<div><div>HTML</div></div>```html
if (((field[ ] ) && (field[ ] )) || (field[ ] ))
```

### For Each Statements:

Use the for.each statement by itself:

<div><div>HTML</div></div>```html
for.each({"test data"})
for.each({block "<table><tr><td>Some text</td></tr></table>"})
for.each({image: "<img src="http://imagefile.jpg">"})
```

Or combined with an IF statement:

<div><div>HTML</div></div>```html
if(condition) {block "for.each({"test data"})"}
if(condition) {block "for.each({block "<table><tr><td>Some text</td></tr></table>"})"}
if(condition) {block "for.each({image: "<img src="http://imagefile.jpg">"})"}
```

## Content Types

Text: Should only contain text, no HTML.

Example:

<div><div>HTML</div></div>```html
{ "Here is some text" }
```

Image: Should only contain an image tag.

Example:

<div><div>HTML</div></div>```html
{ image"<img src="http://imagefile.jpg">" }
```

Block: Can contain anything including code.

Example :

<div><div>HTML</div></div>```html
{ block"<table><tr><td>Some text</td></tr></table>" }
```

---

## Web and Text Versions

**Web versions**

- Continue to use the ##webversionurl## tag and Connect will handle the rest.
- If the client would like different content on their web version vs email message, you can use the following:

<div><div>HTML</div></div>```html
if (content[type] == "email" ) or if (content[type] == "webversion")
```

**Text Versions**

- Use the "Auto Generate Text Version" option in CONNECT or leave it to the AM.
- No separate text version logic required.

## System Variables

These variables provide data from the system for various use cases. They all begin with "system" and are proceeded by the variable name.

Eg. ##system:deploymentid##

</article><table border="1" id="bkmrk-variable-description" style="border-collapse: collapse; width: 100%;"><tbody><tr><td style="width: 50%;">Variable</td><td style="width: 50%;">Description</td></tr><tr><td style="width: 50%;">deploymentid</td><td style="width: 50%;">Provides the ID of the deployment at the time of send and is great for adding context to other tracking code.</td></tr></tbody></table>

<article class="article-body" id="bkmrk-%C2%A0"></article>