Loop index inside a switch content builder How would one construct this? I have built a little content builder and wish now to change the layout HTML on the fly when there are more than one matrix block.

In the example below, this is just one section of the builder and the one I would like to change.

Basically 'move' the block.text part above the image every 2nd time in the loop. I have looked at batch and loopindex but having trouble for the last few hours. Can someone please help with this?

Builder code:

{% case "splitImageAndText" %}
    &lt;div class="grid-x align-center paddingBottom"&gt;
        {% set images = block.imagePart %}

        {% if images and images|length %}
            {% set image = block.imagePart.all() %}

            {# Loop through the images #}
            {% for image in images.all() %}
                &lt;div class="cell medium-6 small-12"&gt;
                    &lt;div class="bg-content" style="background-image:url('{{ image.getUrl() }}');"&gt;&lt;/div&gt;
                &lt;/div&gt;
            {% endfor %}
        {% endif %}

        &lt;div class="cell medium-6 small-12 pull-left"&gt;
            {{ block.textPart }}
        &lt;/div&gt;
    &lt;/div&gt;
I belive you can use {% if loop.index is even %} or {% if loop.index is odd %}