Skip to content

CMS Grid Tag Reference

The {% cmsgrid %} tag provides a powerful way to display collections of content in customizable grid layouts with built-in styling and helper methods.

{% cmsgrid objects from 'collection' with 'classes' as 'tag' %}
{# Template content with {{ object }} and {{ collection }} variables #}
{% endcmsgrid %}
  • objects (required) - Array of objects to display
  • from 'collection' (optional) - Collection name, available as {{ collection }} variable
  • with 'classes' (optional) - CSS classes for the grid container
  • as 'tag' (optional) - HTML tag for grid items (default: div)
{% cmsgrid cms.collection.objects('blog') from 'blog' with 'blog compact' %}
<h3>{{ object.title }}</h3>
<p>{{ object.summary }}</p>
<time>{{ cms.render.grid.date(object.date) }}</time>
{% endcmsgrid %}
{% cmsgrid cms.collection.objects('blog') from 'blog' with 'blog list' %}
{% include 'grid/blog.twig' %}
{% endcmsgrid %}
{% cmsgrid cms.collection.objects('products') from 'products' with 'products grid' as 'article' %}
<h4>{{ object.name }}</h4>
<span class="price">{{ object.price|price }}</span>
{% endcmsgrid %}

Each object in the collection array with all its properties:

{{ object.title }}
{{ object.summary }}
{{ object.date }}
{{ object.image }}
{{ object.tags }}

The collection name from the from parameter:

{% if collection == 'blog' %}
<div class="blog-specific-content">...</div>
{% endif %}

Access via cms.render.grid.* for formatted HTML output:

{{ cms.render.grid.date(object.date, 'relative') }} {# "2 days ago" #}
{{ cms.render.grid.date(object.date, 'short') }} {# "Mar 15, 2024" #}
{{ cms.render.grid.excerpt(object.summary, 150) }} {# Truncated with HTML wrapper #}
{{ cms.render.grid.tags(object.tags) }} {# Formatted tag list #}
{{ cms.render.grid.tags(object.tags, '/tag/') }} {# With links #}
{{ cms.render.grid.price(object.price) }} {# $19.99 with HTML wrapper #}
{{ cms.render.grid.meta(object.author) }} {# Formatted meta data #}

Use cms.render.image() with the object and collection context:

{% if object.image %}
{{ cms.render.image(object, {w: 400}, {collection: collection, property: 'image'}) }}
{% endif %}
  • Displays image, title, date, summary, and tags
  • Optimized for blog posts and articles
  • Shows date, title, content excerpt
  • Designed for news feeds and updates
  • Basic image, title, and summary layout
  • Works with any collection type

The grid system includes comprehensive CSS with design system variables:

  • compact - Smaller cards and gaps
  • wide - Larger cards and spacing
  • list - Single column layout
  • masonry - Masonry-style layout
  • gap-sm, gap-md, gap-lg, gap-xl - Control grid gaps
  • padding-sm, padding-md, padding-lg - Control card padding
  • no-border - Remove card borders
  • no-shadow - Remove shadows and hover effects
  • flat - Completely flat styling
{% cmsgrid cms.collection.objects('products') from 'products' with 'products grid compact' %}
{% if object.image %}
{{ cms.render.image(object, {w: 300, h: 300}, {collection: collection, property: 'image'}) }}
{% endif %}
<h4>{{ object.name }}</h4>
<p class="price">{{ cms.render.grid.price(object.price) }}</p>
{% if object.sale_price %}
<p class="sale">{{ cms.render.grid.price(object.sale_price) }}</p>
{% endif %}
{% endcmsgrid %}
{% cmsgrid cms.collection.objects('team') from 'team' with 'team grid' %}
{{ cms.render.image(object, {w: 200, h: 200}, {collection: collection, property: 'photo'}) }}
<h3>{{ object.name }}</h3>
<p class="role">{{ object.position }}</p>
<p>{{ cms.render.grid.excerpt(object.bio, 100) }}</p>
{% endcmsgrid %}
{% cmsgrid cms.collection.objects('news') from 'feed' with 'feed list' %}
{% include 'grid/feed.twig' %}
{% endcmsgrid %}
{% cmsgrid cms.collection.objects('mixed') from collection_name %}
{% if collection == 'blog' %}
{% include 'grid/blog.twig' %}
{% elseif collection == 'products' %}
<h4>{{ object.name }}</h4>
<p>{{ cms.render.grid.price(object.price) }}</p>
{% else %}
{% include 'grid/generic.twig' %}
{% endif %}
{% endcmsgrid %}
{% set collection_type = get.type|default('blog') %}
{% cmsgrid cms.collection.objects(collection_type) from collection_type with 'responsive-grid' %}
{# Template adapts based on collection type #}
{% endcmsgrid %}
  1. Use from parameter - Always specify collection for proper image handling
  2. Leverage helper methods - Use cms.render.grid.* for consistent formatting
  3. Include built-in templates - Saves time and ensures consistency
  4. Combine CSS classes - Mix layout, spacing, and style classes as needed
  5. Handle empty states - Check for content before displaying

The {% cmsgrid %} tag provides a flexible, powerful system for displaying content grids while maintaining design consistency and providing helpful formatting utilities.