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
<ul>
) - add a (or multiple) entry to that drop down (to create the
<li>
)
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 %}
<li class="nav-link heading> {{ 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 #}
<ul class="dropdown">
{# ERROR - cannot get the entry inside - this is where I need help #}
{% set entries = child.entry.all() %}
{% for entry in entries %}
<li>{{ entry.title }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
</li>
{% 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
{% if child.type.handle == 'dropDown' %}
? At first sight, it looks fine (without being able to see all field handles'.