<p>Your above code is not working because you are using "block" instead of "item" in your children. So...</p>

<pre><code>{% for item in block.children %}
    {% switch item.type.handle %}
</code></pre>

<p>You don't necessarily need to do a switch here, you could do a series of includes and make their file names match your block type... so "_includes/neo/box.twig" and "_includes/neo/image.twig"</p>

<p>In the example below I am replacing "item" with "child" to explain it better.</p>

<pre><code>{% for block in entry.MatrixNeo.level(1) %}
      &lt;h2&gt;{{ block.mainTitle }}&lt;/h2&gt;
      {% for child in block.children %}
           {% include "_includes/neo/" ~ child.type %}
      {% endfor %}
    {% endfor %}
</code></pre>

CC BY-SA 3.0
2016-09-01T13:42:48.883Z
2016-09-01T13:42:48.883Z
AbbeyDesign
<p>You must call the inner blocks (level2, level3 and so on) like the first level</p>

<pre><code>{% if entry.bodyMain is defined and entry.bodyMain | length %}
    {% nav block in entry.bodyMain.level(1) %}
        {% switch block.type.handle %}

            {% case 'accordion' %}
                &lt;ul class="accordion accordion-2"&gt;

                    {% nav block in block.children %}
                        {% switch block.type.handle %}

                            {% case 'timeBlock' %}
                                &lt;li&gt;
                                    &lt;a class="opener" href="#"&gt;{{ block.heading }}&lt;/a&gt;
                                    &lt;div class="slide"&gt;
                                        {{ block.body }}
                                    &lt;/div&gt;
                                &lt;/li&gt;

                        {% endswitch %}
                    {% endnav %}

                &lt;/ul&gt;

        {% endswitch %}
    {% endnav %}
{% endif %}
</code></pre>

<p>Or you can do it like this:</p>

<pre><code>{% if entry.bodyMain is defined and entry.bodyMain | length %}
    {% nav block in entry.bodyMain.level(1) %}
        {% switch block.type.handle %}

            {% case 'accordion' %}
                &lt;ul class="accordion accordion-2"&gt;
                    {% for block in block.children %}
                        {% include "_includes/_blocks/" ~ block.type %}
                    {% endfor %}
                &lt;/ul&gt;

        {% endswitch %}
    {% endnav %}
{% endif %}
</code></pre>

<p>For that you must build a file with this content:</p>

<pre><code>&lt;li&gt;
    &lt;a class="opener" href="#"&gt;{{ block.heading }}&lt;/a&gt;
    &lt;div class="slide"&gt;
        {{ block.body }}
    &lt;/div&gt;
&lt;/li&gt;
</code></pre>

CC BY-SA 3.0
2017-10-05T06:45:56.310Z
2017-10-05T06:45:56.310Z
The Frog
<p>I have a question. How can I output the Childs from a Neo (Neo Plugin) Block?</p>

<p>With this code, i get the output for all level 1 blocks but i don't get a output for the deeper levels.</p>

<p>And how can I handle different child templates for the Output?</p>

<p>My idea is to have a switch with different case for the level 2 output. Because i've different child block options.</p>

<pre><code>{% for block in entry.MatrixNeo.level(1) %}
    {% switch block.type.handle %}

        {% case 'title' %}
            &lt;h2&gt;{{ block.mainTitle }}&lt;/h2&gt;


        {% case 'boxes' %}
             &lt;h2&gt;{{ block.mainTitle }}&lt;/h2&gt;   

            {% for item in block.children %}
                {% switch block.type.handle %}

                    {% case 'box' %}
                        &lt;h2&gt;{{ block.mainTitle }}&lt;/h2&gt;

                        {% case 'image' %}
                        &lt;h2&gt;{{ block.mainTitle }}&lt;/h2&gt;

                {% endswitch %}
            {% endfor %}

    {% endswitch %}
{% endfor %}
</code></pre>

<p>Can somebody help me out, please?</p>

<p>=====================</p>

<p>UPDATE</p>

<p>Now my code works fine but i've a new questione:</p>

<p>How can i output a real Matix-Field in a child element (level 2 in Neo).</p>

<p>My Code:</p>

<pre><code>{% nav block in entry.myField.level(1) %}
    {% switch block.type.handle %}
        {% case 'title' %}
            &lt;hgroup&gt;
                &lt;h2&gt;{{ block.mainTitle }}&lt;/h2&gt;
                &lt;h4&gt;{{ block.subTitle }}&lt;/h4&gt;
            &lt;/hgroup&gt;

        {% case 'intro' %}
            &lt;section class="block"&gt;
                {% for item in block.children %}
                    {% include "_includes/elements/" ~ item.type %}
                {% endfor %}
            &lt;/section&gt;

    {% endswitch %}
{% endnav %}
</code></pre>

<p>The child Code:</p>

<pre><code>&lt;div class="box"&gt;
    &lt;h2&gt;{{ item.mainTitle }}&lt;/h2&gt;

    {% for button in block.myButton %}
        {% switch button.type %}
            {% case 'buttonIntern' %}
                &lt;a class="button" href="{{ button.linkIntern }}"&gt;{{ button.linkText }}&lt;/a&gt;

            {% case 'buttonExtern' %}
                &lt;a class="button" target="_blank" href="{{ button.linkIntern }}"&gt;{{ button.linkExtern }}&lt;/a&gt;

        {% endswitch %}
    {% endfor %}

&lt;/div&gt;
</code></pre>

CC BY-SA 3.0
2016-08-31T19:08:33.687Z
Is `MatrixNeo` a native [Matrix](https://craftcms.com/docs/matrix-fields) field or a [Neo](https://github.com/benjamminf/craft-neo) field from the Neo plugin? And what type of field is `children` in `block.children`?
Brad Bell
CC BY-SA 3.0
2016-09-01T06:26:52.897Z
Yes, the Neo-Plugin. My idea is to have a `switch` with different `case` in the level 2 output. Because i've different child block options.
The Frog
CC BY-SA 3.0
2016-09-05T12:49:17.053Z
Per your updated question. When I see people putting a Matrix within a Neo my first question is why? I can't think of any reason(there might be some) that if you've committed to using NEO, you'd need a Matrix field. You could create a "button" block type in NEO which has two children; one External Link and one Internal Link and use the same code approach as the original answer.
AbbeyDesign
CC BY-SA 3.0
2016-09-05T13:12:33.820Z
Per your updated code, maybe the issue is you have button.linkIntern as the link in your buttonExtern call.
AbbeyDesign
CC BY-SA 3.0
2016-09-08T07:53:40.833Z
You are right, it make no sense at all. Now I build it as a Neo block, but I can't output the button in the 3th level with the some technic as the level 2 blocks. Can you tell me how to output the 3th level blocks.
The Frog
<layout><plugin-neo>
Craft Neo – childs Output
# Craft Neo – childs Output

(Asked by: username_0 on 2016-08-31)

I have a question. How can I output the Childs from a Neo (Neo Plugin) Block?
With this code, i get the output for all level 1 blocks but i don't get a output for the deeper levels.
And how can I handle different child templates for the Output?
My idea is to have a switch with different case for the level 2 output. Because i've different child block options.
{% for block in entry.MatrixNeo.level(1) %}
    {% switch block.type.handle %}

        {% case 'title' %}
            {{ block.mainTitle }}


        {% case 'boxes' %}
             {{ block.mainTitle }}   

            {% for item in block.children %}
                {% switch block.type.handle %}

                    {% case 'box' %}
                        {{ block.mainTitle }}

                        {% case 'image' %}
                        {{ block.mainTitle }}

                {% endswitch %}
            {% endfor %}

    {% endswitch %}
{% endfor %}

Can somebody help me out, please?
=====================
UPDATE
Now my code works fine but i've a new questione:
How can i output a real Matix-Field in a child element (level 2 in Neo).
My Code:
{% nav block in entry.myField.level(1) %}
    {% switch block.type.handle %}
        {% case 'title' %}
            
                {{ block.mainTitle }}
                {{ block.subTitle }}
            

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

    {% endswitch %}
{% endnav %}

The child Code:

    {{ item.mainTitle }}

    {% for button in block.myButton %}
        {% switch button.type %}
            {% case 'buttonIntern' %}
                {{ button.linkText }}

            {% case 'buttonExtern' %}
                {{ button.linkExtern }}

        {% endswitch %}
    {% endfor %}

**Tags:** layout, plugin-neo
> **Comments:**
> **username_1**: Is `MatrixNeo` a native [Matrix](https://craftcms.com/docs/matrix-fields) field or a [Neo](https://github.com/benjamminf/craft-neo) field from the Neo plugin? And what type of field is `children` in `block.children`?  
> **username_0**: Yes, the Neo-Plugin. My idea is to have a `switch` with different `case` in the level 2 output. Because i've different child block options.  
> **username_2**: Per your updated question. When I see people putting a Matrix within a Neo my first question is why? I can't think of any reason(there might be some) that if you've committed to using NEO, you'd need a Matrix field. You could create a "button" block type in NEO which has two children; one External Link and one Internal Link and use the same code approach as the original answer.  
> **username_2**: Per your updated code, maybe the issue is you have button.linkIntern as the link in your buttonExtern call.  
> **username_0**: You are right, it make no sense at all. Now I build it as a Neo block, but I can't output the button in the 3th level with the some technic as the level 2 blocks. Can you tell me how to output the 3th level blocks.  

---

## 2 answers

### Answer by username_2 on 2016-09-01. Score: 2 | Accepted answer

Your above code is not working because you are using "block" instead of "item" in your children. So...
{% for item in block.children %}
    {% switch item.type.handle %}

You don't necessarily need to do a switch here, you could do a series of includes and make their file names match your block type... so "_includes/neo/box.twig" and "_includes/neo/image.twig"
In the example below I am replacing "item" with "child" to explain it better.
{% for block in entry.MatrixNeo.level(1) %}
      {{ block.mainTitle }}
      {% for child in block.children %}
           {% include "_includes/neo/" ~ child.type %}
      {% endfor %}
    {% endfor %}


---

### Answer by username_0 on 2017-10-05. Score: 1

You must call the inner blocks (level2, level3 and so on) like the first level
{% if entry.bodyMain is defined and entry.bodyMain | length %}
    {% nav block in entry.bodyMain.level(1) %}
        {% switch block.type.handle %}

            {% case 'accordion' %}
                

                    {% nav block in block.children %}
                        {% switch block.type.handle %}

                            {% case 'timeBlock' %}
                                
                                    {{ block.heading }}
                                    
                                        {{ block.body }}
                                    
                                

                        {% endswitch %}
                    {% endnav %}

                

        {% endswitch %}
    {% endnav %}
{% endif %}

Or you can do it like this:
{% if entry.bodyMain is defined and entry.bodyMain | length %}
    {% nav block in entry.bodyMain.level(1) %}
        {% switch block.type.handle %}

            {% case 'accordion' %}
                
                    {% for block in block.children %}
                        {% include "_includes/_blocks/" ~ block.type %}
                    {% endfor %}
                

        {% endswitch %}
    {% endnav %}
{% endif %}

For that you must build a file with this content:

    {{ block.heading }}
    
        {{ block.body }}


---

