High level of personalization for your e-mails, landing pages and text messages using Twig syntax.
Support for Custom Objects in Mautic has added a new opportunity to process content in various channels. With this plugin, Mautic users can define Custom Objects with custom fields and create multiple custom items of each type, associating them with Contact or Company entities.
For more information, visit our Github page.
Wondering how to use Custom Objects in the Twig Templates plugin? It's simple! Just use the getCustomObjectItems method:
Parameters:
This tag returns an array of customObjectItems. By default, each Item has two core parameters:
To display the value of a custom field for an item, use the getCustomObjectFieldValue tag:
This will display the value of the custom field defined with the given alias.
This snippet displays the changelog on our page
Check it out here
{% set customObject = getCustomObjectItems('changelogs', 1000, 1, 'name', 'DESC') %} {% for item in customObject%} <h3>{{ item.name}}</h3> <a href="/{{item.findCustomFieldValueForFieldAlias('product').value}}"> {{ getCustomObjectFieldValue(item, 'product') }}</a> {{ getCustomObjectFieldValue(item, 'version') }} </p> {{ getCustomObjectFieldValue(item, 'content') | raw }} <br /><br /> {% endfor %}
If you want to display last order related to a contact
{% if contact.id is defined %} {% set customObject = getCustomObjectItems('orders', 1, 1, 'id', 'DESC', null, contact.id) %} {% for item in customObject%} Your last order number #{{ item.name}} was ordered {{ getCustomObjectFieldValue(item, 'dateOrdered') }} {% endfor %} {% endif %}