Secondary Navigation root path HTL code explanation | Community
Skip to main content
July 25, 2023
Solved

Secondary Navigation root path HTL code explanation

  • July 25, 2023
  • 2 replies
  • 735 views

I have created a "Secondary Navigation" component 

and while creating backend HTL for this, I'm unable to achieve the desired output.

 

As I want it to take the "Navigation Root" path, whatever path has been provided instead of "currentPage" and iterate in that path to provide the child pages of the path provided in the "Navigation Root".

 

<li class="nav navbar-nav navbar-left" data-sly-repeat="${currentPage.listChildren}">
<a href="${item.path}.html">${item.title}</a>
</li>

 

Please provide the correct backend HTL code along with the java code (sling model).

Also explain the logic.

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 EstebanBustamante

If you are referring to the AEM core components, you can check the code by yourself due the project is open source, here is the class you are looking for: https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/NavigationImpl.java 

 

You can always extend and customize the model by following the delegation pattern, you can learn more here: 

https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models 
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/customizing.html?lang=en#customizing-the-logic-of-a-core-component 

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
July 25, 2023

If you are referring to the AEM core components, you can check the code by yourself due the project is open source, here is the class you are looking for: https://github.com/adobe/aem-core-wcm-components/blob/main/bundles/core/src/main/java/com/adobe/cq/wcm/core/components/internal/models/v1/NavigationImpl.java 

 

You can always extend and customize the model by following the delegation pattern, you can learn more here: 

https://github.com/adobe/aem-core-wcm-components/wiki/Delegation-Pattern-for-Sling-Models 
https://experienceleague.adobe.com/docs/experience-manager-core-components/using/developing/customizing.html?lang=en#customizing-the-logic-of-a-core-component 

Esteban Bustamante
arunpatidar
Community Advisor
Community Advisor
July 26, 2023

You can't do this with HTL alone.

You have to write sling model to convert navigation root to Page object and then iterate for children.

Arun Patidar