1

I have a Matrix field with 4 Block types. I loop through them like this

{% for block in entry.MatrixFieldHandle %}
    {% set type = block.type.handle %}

    {% switch type %}
        {% case 'BlockType1' %}
            {{ block.fieldHandle }}

        {% case 'BlockType2' %}
            {{ block.fieldHandle }}

within one of these cases, I need to loop through the entries:

{% case 'BlockType3' %}
    {% for row in block|batch(2) %}
        <div class="row">

        {% for block in row %}
            <div class="col">{{ block.fieldHandle }}</div>
        {% endfor %}
    </div>
{% endfor %}

The html output is close, but I do not get any content displayed. What is wrong?

1 Answer 1

4

I'm assuming you are talking about your block type having a Entries field within.

You simply loop through it like this:

{% case 'BlockType3' %}
<div class="row">
{% for entry in block.entriesFieldHandle %}
    <div class="col">{{ entry.title }}</div>
{% endfor %}
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.