Overview

A Repeater field gives you flexibility, and you can decide how many blocks you want to create during the editing process.

For example, imagine you want to create a slider on the product page. Each slide in the slider should contain a title and an image. You're not sure, however, how many slides you'll need. Sometimes it might be two slides, sometimes it could be 10. This is what Repeater was created for. You can add a Text and Image field to a Repeater, and then in the editing view, you can add as many slides as you want. Each slide will contain both a Text and Image field. In addition, you can also point out which field (that already exists in the Repeater) will be used as the title for the single instance of the Repeater. 



Setup

Min number of instances - Minimum number of “instances” (or “blocks”) that you need to create during editing

Max number of instances - Maximum number of “instances” (or “blocks”) that you need to create during editing

Single instance title - Instead of generic “item” you can name your “instances" (or “blocks”) for a better and easier editing experience. For example for Slider, a single instance could be Slide.

Example Usage

{% assign scope = product.metafields.airf %}

{% assign slider = scope.slider %}

{% if slider and slider != blank %}

    {% for row in slider.rows %}

        Row Data 

        {% for row_field in row %}

            {% comment %} Show ech field in row {% endcomment %}

            <div id="{{row_field.key}}">

                <span>{{row_field.label}}: {{ scope[row_field.key] }}</span>

            </div>


            {% comment %} Conditional show items, for example you can decide which html tag to use {% endcomment %}

            {% if row_field.key contains "XXX" %}

                <h2 id="{{row_field.key}}">{{ scope[row_field.key] }}</h2>

            {% endif %}

        {% endfor %}

    {% endfor %}

{% endif %}