Twig Templates
Custom Objects Support

High level of personalization for your e-mails, landing pages and text messages using Twig syntax.     

Custom Objects in Mautic: Unlocking New Opportunities

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:

getCustomObjectItems(alias, limit, page, orderBy, orderDirection, search, contactId)

Parameters:

  • alias - Custom Object alias
  • limit - limit results to display (default 1000)
  • page - page number of results (default 1)
  • orderBy - id/name (default ID)
  • orderDirection - ASC/DESC (default DESC)
  • search - search fulltext string (default null)
  • contactId - ID of contacts related items (default null)

This tag returns an array of customObjectItems. By default, each Item has two core parameters:

  • id
  • name

To display the value of a custom field for an item, use the getCustomObjectFieldValue tag:

getCustomObjectFieldValue(item, 'alias')

This will display the value of the custom field defined with the given alias.

Example of display items

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 %}

Example of display items assigned to contact

 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 %}
Built on Unicorn Platform