<p>According to the screenshots, you have 2 nesting levels. I guess you can solve this by querying for children a second time.</p>
<p>But I'd like to propose a simpler solution. Keep the code like it is, but allow multiple dropdowns in NEO and add the entry field to the dropdown element.</p>
<p>This way you save one nesting level and have the same result.</p>
<hr />
<p>If you want to keep NEO like it is, you'll need to query the children again.</p>
<pre><code>{# Neo container #}
{% set navItems = navigation.navigationMatrix.level(1).all() %}

{# Top level  #}
{% for block in navItems %}

  &lt;li class=&quot;nav-link heading&gt; {{ block.plainText }}

    {# Cycle over dropDown as its the only child #}
    {% for child in block.children %}
      
      {# Could use a switch - but there is only one right now #}
      {% if child.type.handle == 'dropDown' %}

        {# Create the drop down #}
        &lt;ul class=&quot;dropdown&quot;&gt;

          {# This is wehere you need to get NEO children first #}
          {% set dropdownEntries = child.children %}

          {% for dropdownEntry in dropdownEntries %}
            &lt;li&gt;{{ dropdownEntry.entry.title }}&lt;/li&gt;
          {% endfor %}
          
        &lt;/ul&gt;

      {% endif %}

    {% endfor %}
  &lt;/li&gt;
{% endfor %}
</code></pre>

CC BY-SA 4.0
2022-07-05T12:20:02.493Z
2022-07-05T12:20:02.493Z
Max Strebel
<p>I'm a newbie at using Neo and am finding it hard to get the concept correct for nesting and retrieving child elements.</p>
<p>I have been trying to retrieve them by creating element queries, but I am unable to find them.</p>
<p>My Neo set up is:</p>
<ol>
<li>Add a nav item - which you can title (plainText)</li>
<li>add a drop down (this is a empty NEO block type to trigger the code to add a <code>&lt;ul&gt;</code>)</li>
<li>add a (or multiple) entry to that drop down (to create the <code>&lt;li&gt;</code>)</li>
</ol>
<p><a href="https://i.sstatic.net/pBEU5.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/pBEU5.png" alt="enter image description here" /></a></p>
<p><strong>EDIT:</strong> I have added the Neo fields as well:</p>
<p><a href="https://i.sstatic.net/e5dwM.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/e5dwM.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/Og2tJ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/Og2tJ.jpg" alt="enter image description here" /></a></p>
<p><a href="https://i.sstatic.net/zRWKU.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/zRWKU.jpg" alt="enter image description here" /></a></p>
<p><strong>I guess this would be a good point to ask, is this to many level down already?</strong></p>
<p>When fully input the layout looks like this:</p>
<p><a href="https://i.sstatic.net/ujFaQ.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ujFaQ.jpg" alt="enter image description here" /></a></p>
<p>To try and render this code I have used for loops but I am missing something about to get the elements inside of the drop down matrix (so any help here would be great).</p>
<pre><code>{# Neo container #}
{% set navItems = navigation.navigationMatrix.level(1).all() %}

{# Top level  #}
{% for block in navItems %}

  &lt;li class=&quot;nav-link heading&gt; {{ block.plainText }}

    {# Cycle over dropDown as its the only child #}
    {% for child in block.children %}
      
      {# Could use a switch - but there is only one right now #}
      {% if child.type.handle == 'dropDown' %}

        {# Create the drop down #}
        &lt;ul class=&quot;dropdown&quot;&gt;

          {# ERROR - cannot get the entry inside - this is where I need help #}
          {% set entries = child.entry.all() %}

          {% for entry in entries %}
            &lt;li&gt;{{ entry.title }}&lt;/li&gt;
          {% endfor %}
          
        &lt;/ul&gt;

      {% endif %}

    {% endfor %}
  &lt;/li&gt;
{% endfor %}
</code></pre>
<p>Any help on this would be great - I have a feeling that i have missed some core concept in the structure NEO. The original NEO component I had designed was more complicated than this, but I decided to dull it back to make it work, but to my shame have failed at making the simple version work.</p>
<p>If you have any questions or need more information then please let me know.</p>
<p>W</p>

CC BY-SA 4.0
2022-07-04T20:32:41.977Z
Are you sure the type is 'dropDown'? Does it work if you remove the check (`{% if child.type.handle == 'dropDown' %}`? At first sight, it looks fine (without being able to see all field handles'.
Max Strebel
CC BY-SA 4.0
2022-07-04T21:21:55.557Z
@MaxStrebel - Thanks for the reply: I've added some new screen shots, hope that is help. It works up until I try and get the Entry. What I've found to be an issue if running for loops and setting variables to what I believed would be an array.
Wally
<matrix><plugin-neo>
NEO plugin - How to access child elements
# NEO plugin - How to access child elements

(Asked by: username_0 on 2022-07-04)

I'm a newbie at using Neo and am finding it hard to get the concept correct for nesting and retrieving child elements.
I have been trying to retrieve them by creating element queries, but I am unable to find them.
My Neo set up is:

Add a nav item - which you can title (plainText)
add a drop down (this is a empty NEO block type to trigger the code to add a )
add a (or multiple) entry to that drop down (to create the )


EDIT: I have added the Neo fields as well:



I guess this would be a good point to ask, is this to many level down already?
When fully input the layout looks like this:

To try and render this code I have used for loops but I am missing something about to get the elements inside of the drop down matrix (so any help here would be great).
{# Neo container #}
{% set navItems = navigation.navigationMatrix.level(1).all() %}

{# Top level  #}
{% for block in navItems %}

  

          {# ERROR - cannot get the entry inside - this is where I need help #}
          {% set entries = child.entry.all() %}

          {% for entry in entries %}
            {{ entry.title }}
          {% endfor %}
          
        

      {% endif %}

    {% endfor %}
  
{% endfor %}

Any help on this would be great - I have a feeling that i have missed some core concept in the structure NEO. The original NEO component I had designed was more complicated than this, but I decided to dull it back to make it work, but to my shame have failed at making the simple version work.
If you have any questions or need more information then please let me know.
W

**Tags:** matrix, plugin-neo
> **Comments:**
> **username_1**: Are you sure the type is 'dropDown'? Does it work if you remove the check (`{% if child.type.handle == 'dropDown' %}`? At first sight, it looks fine (without being able to see all field handles'.  
> **username_0**: @MaxStrebel - Thanks for the reply: I've added some new screen shots, hope that is help. It works up until I try and get the Entry. What I've found to be an issue if running for loops and setting variables to what I believed would be an array.  

---

## 1 answers

### Answer by username_1 on 2022-07-05. Score: 1

According to the screenshots, you have 2 nesting levels. I guess you can solve this by querying for children a second time.
But I'd like to propose a simpler solution. Keep the code like it is, but allow multiple dropdowns in NEO and add the entry field to the dropdown element.
This way you save one nesting level and have the same result.

If you want to keep NEO like it is, you'll need to query the children again.
{# Neo container #}
{% set navItems = navigation.navigationMatrix.level(1).all() %}

{# Top level  #}
{% for block in navItems %}

  

          {# This is wehere you need to get NEO children first #}
          {% set dropdownEntries = child.children %}

          {% for dropdownEntry in dropdownEntries %}
            {{ dropdownEntry.entry.title }}
          {% endfor %}
          
        

      {% endif %}

    {% endfor %}
  
{% endfor %}


---

