Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guideDeveloper guideAdmin guide
Company siteHelp center
English
  • Русский
  • English
v74
  • v74
  • v73
  • v72
Login
  • User documentation
  • FAQ
  • Altcraft glossary
  • Profiles and databases
  • Communication channels
  • Segmentation
  • Message templates
    • Working with message templates
    • Visual editor for email-template
    • Template fragments
    • Image gallery
    • Content personalization
    • Creating tables based on array elements
    • Block editor for email template
    • Altcraft Variables and Functions
      • Logical expressions in messages
      • Loops in messages
      • Market variables in templates
      • Using the JSONPath functionality
    • Dynamic content in messages
    • Importing and exporting a message template
    • Importing a template from a third-party service
    • Exporting a template from Pixcraft
  • Mailings
  • Campaigns
  • Automation scenarios
  • Market
  • Loyalty programs
  • Reports and analytics
  • Integrations
  • Weblayers
  • Settings
  • API requests: where to start
  • Changelog
  • library
  • Message templates
  • Altcraft Variables and Functions
  • Loops in messages
Documentation for version v74

Loops in messages

The message supports loops for JSON variables of type "list" [] and "object" {}, as well as access to an object element by key {json.object.name}.

If additional profile fields are inserted as variables into the template, fields of the "Array of Objects" and "Tag" (list of strings) types can also be used in loops.

Nested loops are also possible.

Variables example​

{
"Addresses": ["Barclay street, 244 building", "Green street, 555 building"],
"Information": {
"LJ": [
{ "name": "Optimyss X1", "price": "$10" },
{ "name": "Optimyss X2", "price": "$20" }
],
"Samsung": [{ "name": "Galaktiko 17", "price": "$50" }]
}
}

Loops example​

<!-- Loop by object elements -->
{for $vendor $models = json.Information}
<p>{$vendor}</p>

<ol>
<!-- Nested loop -->
{for $index $model = $models}

<!-- Call elements by key -->
<li>{$model.name} {$model.price}</li>

{else}
<p>Empty array!</p>
{end}
</ol>

{else}
<p>Empty array!</p>
{end}


<h5>Addresses:</h5>
<ol>
<!-- Simple loop by strings list -->
{for $index $address = json.Addresses}
<li>{$address}</li>
{else}
<p>Empty array!</p>
{end}
</ol>

Result​

<h5>New:</h5>

<!-- Loop by object elements -->
<p>LJ<p>
<ol>
<!-- Nested loop. Call elements by key -->
<li>Optimyss X1 $10</li>
<li>Optimyss X2 $20</li>
<ol>

<!-- Loop by object elements -->
<p>Samsyng<p>
<ol>
<!-- Nested loop. Call elements by key -->
<li>Galaktiko 17 $50</li>
<ol>

<h5>Addresses:</h5>
<ol>
<!-- Simple loop by strings list -->
<li>Barclay street, 244 building</li>
<li>Green street, 555 building</li>
</ol>
Last updated on Aug 10, 2022
Previous
Logical expressions in messages
Next
Market variables in templates
  • Variables example
  • Loops example
  • Result
© 2015 - 2025 Altcraft, LLC. All rights reserved.