Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

Display Navigation Title of child pages in Sightly

Avatar

Level 8

Hello Everyone,

 

I can display child pages title using the below Sightly code.

 

<ul data-sly-list="${currentPage.listChildren}">
     <li>${item.title}</li>
</ul>

Is it possible to list the Navigation title of child pages using Sightly? Tried below logic, But no luck

 

<ul data-sly-list="${currentPage.listChildren}">
	<li>${item.navTitle}</li>
</ul>

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 9

@Mahesh_Gunaje : There is no function as navTitle in com.day.cq.wcm.api.Page api.

Please try with: ${item.navigationTitle}

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/api/Pa...

thanks.

View solution in original post

4 Replies

Avatar

Community Advisor

@Mahesh_Gunaje  can you try below code 

<div data-sly-use.page="com.day.cq.wcm.api.Page">
<ul data-sly-list.child="${page.listChildren}">
<li>${child.navigationTitle}</li>
</ul>
</div>
 

Avatar

Correct answer by
Level 9

@Mahesh_Gunaje : There is no function as navTitle in com.day.cq.wcm.api.Page api.

Please try with: ${item.navigationTitle}

https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/wcm/api/Pa...

thanks.

Avatar

Level 8

Hi @Kamal_Kishor 

 

Thanks for the solution. This works.

There is no function as navTitle in com.day.cq.wcm.api.Page api.:  True. Just checked the details.

My query: in the jcr:content, I can see the jcr property as navTitle. So, how come below statement works fine?

<ul data-sly-list="${currentPage.listChildren}">
	<li>${item.navigationTitle}</li>
</ul>

 

Avatar

Level 9

@Mahesh_Gunaje : If you recall, getting page or component values in your HTL/Sightly via sling model (APIs) is by using their getter method name (remove get prefix, and lowercase first letter), so getNavigationTitle becomes navigationTitle.

Usually, you would have seen people naming field values and their getter methods similarly, maybe that's why you felt that way. But as I mentioned earlier, it is based on the getter method name.

In the impl class of your sling model, they would have been getting the value of actual property using their name i.e navTitle

thanks.