Navigation-Component <-- not displaying sub menu items | Community
Skip to main content
Mahen_Govender
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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Only related doc is this one:

https://docs.adobe.com/docs/en/aem/6-1/develop/the-basics/website.html#Creating the Top Navigation Component

but this is for top nav component. 

3 replies

smacdonald2008
Level 10
September 20, 2016

Are you following an online doc so we can try and reproduce your results? 

smacdonald2008
smacdonald2008Accepted solution
Level 10
September 20, 2016

Only related doc is this one:

https://docs.adobe.com/docs/en/aem/6-1/develop/the-basics/website.html#Creating the Top Navigation Component

but this is for top nav component. 

Mahen_Govender
Level 2
September 22, 2016

smacdonald2008 wrote...

Only related doc is this one:

https://docs.adobe.com/docs/en/aem/6-1/develop/the-basics/website.html#Creating the Top Navigation Component

but this is for top nav component. 

 

Hi Scott

Thanks for the response, we are actually using the top-nav, it has just been styled to appear as a side navigation.

I will look through the link, thanks very much