Level 2
September 20, 2016
Solved
Navigation-Component <-- not displaying sub menu items
- September 20, 2016
- 3 replies
- 1777 views
Hi
We have a side nav, that should display sub nav pages, as long as those pages are not hidden from navigation.
However it is behaving strangely:
- If it has one sub item it does not display any submenu items
- If there are more than one sub item it then displays the submenu correctly
To illustrate:
With one sub item:
With two sub items:
The code looks correct to me :
<div class="navigation__wrapper" > <nav class="navigation"> <ul class="navigation__list--one"> <% // get starting point of navigation long absParent = currentStyle.get("absParent", 2L); String navstart = Text.getAbsoluteParent(currentPage.getPath(), (int) absParent); //if not deep enough take current node if (navstart.equals("")) navstart=currentPage.getPath(); Resource rootRes = slingRequest.getResourceResolver().getResource(navstart); Page rootPage = rootRes == null ? null : rootRes.adaptTo(Page.class); String xs = Doctype.isXHTML(request) ? "/" : ""; if (rootPage != null) { Iterator<Page> children = rootPage.listChildren(new PageFilter(request)); while (children.hasNext()) { Page child = children.next(); %> <li class="navigation__item"> <a href="<%= xssAPI.getValidHref(child.getPath()) %>.html" class="navigation__link"> <span><%= xssAPI.getValidHref(child.getTitle()).replace("%20", " ") %></span> <!-- <span class="icon icon-arrow-right-thick iconproperties"></span> --> <span class="icon nav-right-arrow"></span> </a> <ul class="navigation__list--submenu"> <% Iterator<Page> childChildren = child.listChildren(new PageFilter(request)); while (childChildren.hasNext()) { Page childChildChildren = childChildren.next(); %> <li class="navigation__item"> <a href="<%= xssAPI.getValidHref(childChildChildren.getPath()) %>.html" class="navigation__link"> <span><%= xssAPI.getValidHref(childChildChildren.getTitle()).replace("%20", " ") %></span> <span class="icon nav-right-arrow"></span> </a> </li> <% } %> </ul> </li> <% } } %> </ul> </nav> </div>
Any ideas why it would be behaving in this way?
