I have this structure section:
1.0 Nav point level 1
1.1 Nav point level 2
1.2 Nav point level 2
1.3 Nav point level 2
2.0 Nav Point level 1
3.0 Nav Point level 1
I want to show only top level points as long as there is no children ont the current page.
Example:
When im on page 1.0 Nav point level 1
the navi shoud look like above (Because the current page has descendants).
But when im on 2.0 Nav Point level 1
the navi should look like this:
(Everything below level 1 not visible because the current page has no children.)
1.0 Nav point level 1
2.0 Nav Point level 1
3.0 Nav Point level 1
I tried to wrap the children tag into a conditional. But that's not allowed:
{% set topLevel = (entry.level == 1) ? entry : entry.getAncestors().level(1).first() %}
{% if topLevel.hasDescendants %}
<nav class="subNav">
<ul>
{% set subnav = topLevel.getDescendants() %}
{% nav page in subnav %}
<li>
<a href="{{ page.url }}">{{ page.title }}</a>
{% if entry.hasDescendantes %} // this does not work at all.
{% ifchildren %}
<ul>{% children %}</ul>
{% endifchildren %}
{% endif %}
</li>
{% endnav %}
</ul>
</nav>
{% endif %}
I can't wrap my head around it.