Use data from Mautic Custom Objects in your Twig Templates.
getCustomObjectItems
function to fetch data from a specific Custom Object.
getCustomObjectItems(alias, limit, page, orderBy, orderDirection, search, contactId)
What the options mean:
alias
(Required): The unique name (alias) of your Custom Object (e.g., 'orders'
).limit
: How many items to get (default is 1000).page
: Which page of results to get (for pagination, default is 1).orderBy
: How to sort the items ('id'
or 'name'
, default is 'id'
).orderDirection
: Sort direction ('ASC'
for A-Z, 'DESC'
for Z-A, default is 'ASC'
).search
: Text to search for within the items (optional).contactId
: Get items linked only to a specific contact ID. Use contact.id
for the current contact (optional).id
: The item’s ID.name
: The item’s name.fields
: A collection of all the custom field values for that item. You access them using their alias (e.g., item.fields.your_field_alias
).{% set myItems = getCustomObjectItems('orders') %}
), you can loop through them and show their details: