fromtheoutfit / navee

Navigation module for Craft CMS
Other
113 stars 6 forks source link

Nodes accessed through getDescendants don't have 'link' property set. #13

Closed roberttolton closed 8 years ago

roberttolton commented 8 years ago

Hi,

Navee: 1.0.6 Craft: 2.6.2804

I'm having to use the following code with an if statement built around the linkType because the link property of nodes accessed through node.getDescendants (e.g. for building custom navigation trees with children) is empty.

{% nav node in mainNavTopLevel %}
{% if node.hasDescendants() %}
{% set nodeKebab = node.title | lower | kebab %}
<nav id="{{ nodeKebab }}-submenu" class="submenu">
    <ul class="submenu-list submenu-list-{{ mainNavTopLevelCount }}-{{ loop.index0 }}">
        {% set children = node.getDescendants() %}
        {% for child in children %}
        {% if child.linkType == "entryId" %}
        {% set childLink = siteUrl ~ child.entryLink %}
        {% elseif child.linkType == "customUri" %}
        {% set childLink = child.customUri %}
        {% endif %}
        <li class="submenu-item"><a href="{{ childLink }}">{{ child.title }}</a></li>
        {% endfor %}
        <li class="submenu-item"><a class="back-link" href="#">Back</a></li>
    </ul>
</nav>
{% endif %}
{% endnav %}

Instead of just:

{% nav node in mainNavTopLevel %}
{% if node.hasDescendants() %}
{% set nodeKebab = node.title | lower | kebab %}
<nav id="{{ nodeKebab }}-submenu" class="submenu">
    <ul class="submenu-list submenu-list-{{ mainNavTopLevelCount }}-{{ loop.index0 }}">
        {% set children = node.getDescendants() %}
        {% for child in children %}
        <li class="submenu-item"><a href="{{ child.link }}">{{ child.title }}</a></li>
        {% endfor %}
        <li class="submenu-item"><a class="back-link" href="#">Back</a></li>
    </ul>
</nav>
{% endif %}
{% endnav %}

In the above, {{ child.link }} is empty, even when debugging the child property using kint, it's empty.

Thanks,

michaelfromtheoutfit commented 8 years ago

Hey @roberttolton - this has been addressed in 1.0.7. Thanks so much for the feedback, sorry for the delay.

roberttolton commented 7 years ago

Hi @michaelfromtheoutfit I DM'd you on Slack, but I think a similar thing is happening to the active class of nodes accessed through this method too.