Hi,
I have a component which I am including in base page body.
In sling model of the component, how can I get if the current page is Home page or not.
Thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @hptarora,
Can you check once for Context aware configuration available in your application ?
if yes you can take help from context aware config to get the homepage if there is one for the same, if not then you can easily add one for homepage path.
this is very normal implementation in almost all multilingual application.
Hope this will help.
Umesh Thakur
Hi @hptarora
You can define a page property(let's say homePage) where you can author the home page link. Let's say your home page is /content/something/en_us/index
Now your page node contains homePage=/content/something/en_us/index value in crx.
Now in you sling model you can read the homePage property value and can compare with currentPage object which is OOTB and available with @ScriptVariable annotation.
Put a condition if homePage = currentPage.getPath() then you are on Home page else you are on other pages.
@ScriptVariable
private Page currentPage;
@ValueMapValue
private String homePage;
if (StringUtils.isNoneEmpty(currentPage.getPath(), homePage) && StringUtils.equalsIgnoreCase(currentPage.getPath(), homePage)) {
// Home page
}
Thanks!
Hi @hptarora,
Can you check once for Context aware configuration available in your application ?
if yes you can take help from context aware config to get the homepage if there is one for the same, if not then you can easily add one for homepage path.
this is very normal implementation in almost all multilingual application.
Hope this will help.
Umesh Thakur
Views
Likes
Replies