Trying to get the different page title in my sling model | Community
Skip to main content
Level 7
March 4, 2025
Solved

Trying to get the different page title in my sling model

  • March 4, 2025
  • 1 reply
  • 621 views
Hello Team,
 
I have a page which has these title
jcr:title has the value: ABC Page
navTitle has the value: navTitle123
pageTitle has the value: myPageTitle
 
In my custom sling model logic, I have written these statements to get the page title.

 

 

 

 

private Page currentPage; // Initialized properly with annotation. String navTitle = StringUtils.defaultIfEmpty(currentPage.getNavigationTitle(), currentPage.getTitle()); // Displays Navigation title: navTitle123 String newTitle = currentPage.getTitle(); // This displays "ABC Page" instead of "myPageTitle"

 

 

 

When I googled, i came to know that currentPage.getTitle() internally checks for page Title. If its not present, then only it returns jcr:title
 

 

 
So, What I am missing here?
 
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 lukasz-m

Hi @mahesh_gunaje,

I do not thing that there is any fallback. According to official documentation:


Returns the title of the page or null if none defined

So behavior you have described looks to be correct. Probably information you have found are wrong. I would suggest to rely on official documentation as a main source, and in case of doubts, ask the question in this community .🙂

1 reply

lukasz-m
Community Advisor
lukasz-mCommunity AdvisorAccepted solution
Community Advisor
March 4, 2025

Hi @mahesh_gunaje,

I do not thing that there is any fallback. According to official documentation:


Returns the title of the page or null if none defined

So behavior you have described looks to be correct. Probably information you have found are wrong. I would suggest to rely on official documentation as a main source, and in case of doubts, ask the question in this community .🙂

Level 7
March 4, 2025

Thanks @lukasz-m   for your quick help.

I was referring to this one. From many source (Not the official one), I got these details only. May be, this is misleading.

One more help I need. Out of the box breadcrumb feature gives the Navigation title first (if its present). else, Page title. Else, jcr:title

if possible, can you provide me the code snippet from the out of the box breadcrumb feature?

 

Thanks

lukasz-m
Community Advisor
Community Advisor
March 4, 2025