Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Navigation-Component <-- not displaying sub menu items

Avatar

Level 2

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?

1 Accepted Solution

Avatar

Correct answer by
Level 10

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. 

View solution in original post

3 Replies

Avatar

Level 10

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

Avatar

Correct answer by
Level 10

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. 

Avatar

Level 2

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