Twig Schemas Reference
The schema adapter provides access to schema definitions — the blueprints that define object structure for collections.
Listing Schemas
Section titled “Listing Schemas”list()
Section titled “list()”Get all accessible schemas (filtered by edition restrictions).
{% for schema in cms.schema.list() %} <p>{{ schema.id }} — {{ schema.name }}</p>{% endfor %}reserved()
Section titled “reserved()”Get all accessible built-in (reserved) schemas.
{% for schema in cms.schema.reserved() %} <p>{{ schema.id }}</p>{% endfor %}custom()
Section titled “custom()”Get all accessible custom schemas (Pro edition only).
{% if cms.edition.getIsPro() %} {% for schema in cms.schema.custom() %} <p>{{ schema.id }} — {{ schema.name }}</p> {% endfor %}{% endif %}byCategory()
Section titled “byCategory()”Get schemas grouped by their category.
{% for category, schemas in cms.schema.byCategory() %} <h3>{{ category }}</h3> <ul> {% for schema in schemas %} <li>{{ schema.name }}</li> {% endfor %} </ul>{% endfor %}Fetching Schemas
Section titled “Fetching Schemas”Get a single schema definition as an array.
{% set schema = cms.schema.get('blog') %}<h2>{{ schema.name }}</h2><p>{{ schema.description }}</p>
{# Access schema properties #}{% for prop in schema.properties %} <p>{{ prop.name }}: {{ prop.type }}</p>{% endfor %}forCollection()
Section titled “forCollection()”Get the schema assigned to a specific collection.
{% set schema = cms.schema.forCollection('my-blog') %}<p>This collection uses the {{ schema.name }} schema</p>Schema Properties
Section titled “Schema Properties”inheritedProperties()
Section titled “inheritedProperties()”Get all inherited properties for a schema, including the source schema each property comes from.
{% set inherited = cms.schema.inheritedProperties('blog') %}{% for prop in inherited %} <p>{{ prop.field }} ({{ prop.type }}) — inherited from {{ prop.source }}</p>{% endfor %}Returns: Array of objects with keys:
source— schema ID the property is inherited fromfield— property field nametype— property typedefinition— full property definition array
Deck Compatibility
Section titled “Deck Compatibility”isDeckCompatible()
Section titled “isDeckCompatible()”Check if a schema is compatible with deck usage. Decks require specific property types.
{% if cms.schema.isDeckCompatible('blog') %} <p>This schema can be used in decks</p>{% endif %}deckIncompatibleTypes()
Section titled “deckIncompatibleTypes()”Get the list of property types in a schema that are incompatible with deck usage.
{% set incompatible = cms.schema.deckIncompatibleTypes('blog') %}{% if incompatible|length > 0 %} <p>Incompatible types: {{ incompatible|join(', ') }}</p>{% endif %}