


I am trying to get the path of page where the component is currently rendering. Currently my component is in experiece fragment, but I want the path of page where it is rendering.
PageManager pageManager=resourceResolver.adaptTo(PageManager.class);
Page currentPage = pageManager.getContainingPage(resource);
String pagePath = currentPage.getPath();
pagePath is giving me the path of experience fragment I cant get the path of page where it is loading.
Solved! Go to Solution.
Views
Replies
Sign in to like this content
Total Likes
Hi @Ronnie09
Please try this:
@Model(adaptables = {Resource.class })
Public class Model{
@Inject
private Page currentPage;
private String pagePath;
@PostConstruct
protected void init() {
log.debug("** Start of sling Model **");
pagePath = currentPage.getPath();
}
}
Views
Replies
Sign in to like this content
Total Likes
In HTL there is implicit object in sightly
${currentPage.path}