1

I have a matrix field with a Super Table block type. Then I have a matrix field as a field within the Super Table block. I am having trouble filtering by block type from within the child matrix field. Is what I am trying to achieve even possible? Any solution would save me from pulling my hair out any further.

Below is the last attempt I made to filter through before posting here:

{% for block in entry.matrixFieldParent %}

    {% if block.type == "superTableBlock" %}

        {% for row in superTableBlock %}

            {% for block in row.superTableBlock %}

                {% switch block.type %}

                    {% case "contentBlock1" %}

                       {{ block.contentField }}

                    {% case "contentBlock2" %}

                       {{ block.contentField }}

                {% endswitch %}

            {% endfor %}

        {% endfor %}

    {% endif %}

{% endfor %}

edited to include if statement previously left out by mistake

1 Answer 1

2

Firstly, you'll need to change:

{% for row in superTableBlock %} to {% for row in block.superTableBlock %}

So you can reference the Super Table field within your out Matrix field.

You also don't need to loop through {% for block in row.superTableBlock %}

I can't tell if you're looping through the inner Matrix field. Have you tried:

{% for block in entry.matrixFieldParent %}
    {% if block.type == "sectionBuilder" %}
        {% for row in block.sectionBlock %}
            {% for sectionLayout in row.sectionLayout %}
                {% switch sectionLayout.type %}
                    {% case "contentBlock" %}
                       {{ sectionLayout.sectionGrid }}
                    {% case "articlesFeedBlock" %}
                       {{ sectionLayout.sectionBackground }}
                {% endswitch %}
            {% endfor %}
        {% endfor %}
    {% endif %}
{% endfor %}
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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