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

Secondary Navigation root path HTL code explanation

Avatar

Level 1

I have created a "Secondary Navigation" component 

sanchay_0-1690295211784.png

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.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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/w... 

 

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/customiz... 



Esteban Bustamante

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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/w... 

 

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/customiz... 



Esteban Bustamante

Avatar

Community Advisor

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