Looping Through Grids In the Variables Module

carsonsuite - 2 weeks ago

I created and added a Grid into my variables module group, but could not figure out how to loop through it. Most may already know this, but hope this helps others save time if looking through the forum :)


ryanthompson - 2 weeks ago

Try something like this:

{% for grid in variable('example', 'grid_field') %}
    {{ grid.type }} // The grid stream slug
    {{ grid.some_field }} // Maps automatically to the grid entry
{% endfor %}

Check it out: https://pyrocms.com/documentation/grid-field-type/latest#usage/basic-output