Skip to content

Twig Data Reference

The data adapter provides typed access to object properties. Each method has sensible defaults for collection and property names, making single-collection use cases very concise.

Get a raw property value from any object without type coercion.

{{ cms.data.raw('blog', 'my-post', 'title') }}
{{ cms.data.raw('products', 'widget', 'price') }}
ParameterTypeDescription
collectionstringCollection identifier
idstringObject identifier
propertystringProperty name

Get a complete object from a collection. Returns an empty array if not found.

{% set post = cms.data.object('blog', 'my-post') %}
{{ post.title }}

The data adapter can be called directly as a function for backwards compatibility. This is equivalent to raw().

{{ cms.data('blog', 'my-post', 'title') }}

Get text content. Default collection: text, default property: text.

{{ cms.data.text('headline') }}
{{ cms.data.text('headline', {collection: 'custom', property: 'body'}) }}

Get code snippet content. Default collection: code, default property: code.

{{ cms.data.code('example') }}
{{ cms.data.code('example', {collection: 'snippets', property: 'source'}) }}

Get styled text (HTML content from a rich text editor). Default collection: styledtext, default property: styledtext.

{{ cms.data.styledtext('about')|raw }}
{{ cms.data.styledtext('about', {collection: 'pages', property: 'content'})|raw }}

Get a boolean toggle value. Default collection: toggle, default property: status.

{% if cms.data.toggle('maintenance') %}
<div class="maintenance-banner">Site under maintenance</div>
{% endif %}
{{ cms.data.toggle('feature', {collection: 'settings', property: 'enabled'}) }}

Get a date string. Default collection: date, default property: date.

{{ cms.data.date('launch') }}
{{ cms.data.date('event', {collection: 'events', property: 'eventDate'}) }}

Get a number value (returned as string). Default collection: number, default property: number.

{{ cms.data.number('visitors') }}
{{ cms.data.number('price', {collection: 'products', property: 'cost'}) }}

Get a URL string. Default collection: url, default property: url.

<a href="{{ cms.data.url('website') }}">Visit Site</a>
{{ cms.data.url('social', {collection: 'links', property: 'href'}) }}

Get an email address. Default collection: email, default property: email. Supports HTML obfuscation for anti-spam.

{# Plain email #}
{{ cms.data.email('contact') }}
{# HTML-obfuscated email (anti-spam) #}
{{ cms.data.email('contact', {}, true)|raw }}
ParameterTypeDefaultDescription
idstringrequiredObject identifier
optionsarray[]Options with collection and property keys
obfuscateboolfalseHTML-encode the email for anti-spam protection

Get SVG content. Default collection: svg, default property: svg.

{{ cms.data.svg('logo')|raw }}
{{ cms.data.svg('icon', {collection: 'icons', property: 'svgData'})|raw }}

Get color data as an array with hex and oklch properties. colour() is a British spelling alias.

{% set myColor = cms.data.color('brand') %}
{% set myColor = cms.data.colour('brand') %} {# Same thing #}
{# Access color values #}
{{ myColor.hex }} {# #ff0000 #}
{{ myColor.oklch.l }} {# Lightness #}
{{ myColor.oklch.c }} {# Chroma #}
{{ myColor.oklch.h }} {# Hue #}
{# Use with color filters #}
{{ myColor|hex }} {# #ff0000 #}
{{ myColor|oklch }} {# oklch(62.8% 0.25768 29.234) #}
{{ myColor|rgb }} {# rgb(255 0 0) #}
{{ myColor|hsl }} {# hsl(0 100% 50%) #}

Default collection: color, default property: color.

Get image data as an array. Default collection: image, default property: image.

{% set img = cms.data.image('hero') %}
{{ img.filename }}
{{ img.alt }}
{{ img.width }}
{{ img.height }}

For rendering images as HTML, see cms.render.image().

Get gallery data as an array of image objects. Default collection: gallery, default property: gallery.

{% set photos = cms.data.gallery('vacation') %}
{% for photo in photos %}
<p>{{ photo.name }}{{ photo.alt }}</p>
{% endfor %}

For rendering galleries with lightbox support, see cms.render.gallery().

Get file data as an array. Default collection: file, default property: file.

{% set doc = cms.data.file('report') %}
{{ doc.filename }}
{{ doc.size }}
{{ doc.mime }}

For generating download/stream URLs, see cms.media.

Get depot (multi-file storage) data as an array. Default collection: depot, default property: depot.

{% set files = cms.data.depot('documents') %}
{% for file in files %}
<p>{{ file.name }} ({{ file.size }} bytes)</p>
{% endfor %}

For generating download/stream URLs, see cms.media.

All typed data methods accept an options array as the second parameter with these keys:

KeyTypeDescription
collectionstringOverride the default collection
propertystringOverride the default property
{# Using defaults #}
{{ cms.data.text('headline') }}
{# Custom collection and property #}
{{ cms.data.text('headline', {collection: 'pages', property: 'title'}) }}