Conditional statement for nav tag when no children On the menu below I need to change the class on the li from dropdown-submenu to dropdown-item for those entries that don't have children.  Any ideas?

Thanks

{% set pages = craft.entries.section('services') %}
                       {% nav page in pages %}
           &lt;li class="dropdown-submenu"&gt; 
                {{ page.getLink() }}

                {% ifchildren %}
                   &lt;ul class="dropdown-menu" aria-labelledby="dropdownMenuLink"&gt;
                        {% children %}
                    &lt;/ul&gt;
                {% endifchildren %}
            &lt;/li&gt;

        {% endnav %}
Have you tried something like:

&lt;li class="{{ page.getChildren()|length == 0 ? 'dropdown-item' : 'dropdown-submenu' }}"&gt;


If that doesn't work, I suspect you could use {% ifchildren %} in concert with a variable to set the style. In this case, we set the variable to a non-null value if there are children. Then we can use the null-coalescing operator to substitute 'dropdown-item' if there are no children. Like:

{% set listclass = null %}
{% ifchildren %}
    {% set listclass = 'dropdown-submenu' %}
{% endifchildren% }
&lt;li class="{{ listclass ?? 'dropdown-item' }}"&gt;