4

I have a Neo Field: I want to work with blocks up to 3 levels deep.

My output code works fine:

{% nav block in entry.myField.level(1) %}
    {% switch block.type.handle %}
        {% case 'title' %}
            <h2>{{ block.title }}</h2>

        {% case 'blocks' %}
             {% for item in block.children %}
                 {% include "_includes/elements/" ~ item.type %}
             {% endfor %}

    {% endswitch %}
{% endnav %}

But how can I output the deeper block levels? I don't find any way to do this.

Design Frog
  • 133
  • 1
  • 1
  • 4

2 Answers2

3

You take the same approach as the original child.

So you'd nest a {% for 3rdChild in item.children %} in your {% for item in block.children %}

AbbeyDesign
  • 1,527
  • 8
  • 13
1

Not tested – I've no idea if the {% nav %} tag even works properly with Neo, but assuming it does, you're not actually rendering the children for each block with your current code. This might do it:

{% nav block in entry.myField.level(1) %}

    {% switch block.type.handle %}

        {% case 'title' %}
            <h2>{{ block.title }}</h2>

        {% case 'blocks' %}
            {% for item in block.children %}
                {% include "_includes/elements/" ~ item.type %}
             {% endfor %}

    {% endswitch %}

    {% ifchildren %}
        {% children %}
    {% endifchildren %}

{% endnav %}
Mats Mikkel Rummelhoff
  • 22,361
  • 3
  • 38
  • 69