Templating repeatable blocks in a matrix field I have a matrix field that has two different block types. The matrix field is on an entry that lists a number of benefits for a given product on a corporate website. The two different blocks are firstly an &quot;intro&quot; block that has a couple of text fields for a headline and description and then secondly a &quot;benefits&quot; to create a list of benefits. I then output the items in the template as follows:

{% for intro in entry.benefits %}
    {% for image in intro.leadImage %}
        &lt;img class=&quot;headImage&quot; src=&quot;{{ image.getUrl() }}&quot; width=&quot;{{ image.getWidth() }}&quot; height=&quot;{{ image.getHeight() }}&quot; alt=&quot;{{ image.title }}&quot;&gt;
    {% endfor %}
    &lt;h3 class=&quot;sectionHead&quot;&gt;{{ intro.introTitle }}&lt;/h3&gt;
    &lt;p class=&quot;intro&quot;&gt;{{ intro.introParagraph }}&lt;/p&gt;
{% endfor %}

&lt;div class=&quot;details&quot;&gt;
    {% for benefitsItem in entry.benefits %}
        &lt;p&gt;&lt;span class=&quot;orange&quot;&gt;{{ benefitsItem.benefit }}&lt;/span&gt; - {{ benefitsItem.description }}&lt;/p&gt;
    {% endfor %}
&lt;/div&gt;

There are two different for loops, one that lists the &quot;intro&quot; block and one that lists the &quot;benefitsItem&quot; block. The problem I have is that I want to be able to separate lists of benefits into sections by inserting another &quot;intro&quot; block in the CMS content but of course no matter where I order my &quot;intro&quot; blocks in the admin they will always appear above all the benefits where the for loop puts them out. Does anyone know how I would go about creating a matrix field or changing my template so that I can order things as follows:

Intro
Benefit
Benefit
Intro
Benefit
Benefit

Any ideas greatly appreciated. Thanks.
It might be worth checking the types of the matrix block like:

{% for block in entry.benefits.all() %}
    {% switch block.type %}
        {% case "intro" %} {# &lt;=== ASSUMING BLOCK TYPE HANDLE #}
            {% for image in block.leadImage.all() %}
                &lt;img class="headImage" src="{{ image.getUrl() }}" width="{{ image.getWidth() }}" height="{{ image.getHeight() }}" alt="{{ image.title }}"&gt;
            {% endfor %}
            &lt;h3 class="sectionHead"&gt;{{ block.introTitle }}&lt;/h3&gt;
            &lt;p class="intro"&gt;{{ block.introParagraph }}&lt;/p&gt;

        {% case "details" %} {# &lt;=== ASSUMING BLOCK TYPE HANDLE #}
            &lt;div class="details"&gt;
                &lt;p&gt;&lt;span class="orange"&gt;{{ block.benefit }}&lt;/span&gt; - {{ block.description }}&lt;/p&gt;
            &lt;/div&gt;

    {% endswitch %}
{% endfor %}



If you're wanting a list inside of a matrix (matrix in a matrix for the Benefits), I'd suggest killing the Benefits block type and adding a SuperTable or Neo field to the Intro block type then you'll be able to list the benefits below each intro in a for loop.