Hi,
We have a use-case in a component, where we're using nested experience fragments on a page and when I try to get the current page path in a component (nested inside the innermost XF), the get the path of it's parent XF.
For example, we have two XFs - Child XF (/content/experience-fragment/project/child-xf) and Parent XF (/content/experience-fragment/project/parent-xf). And a Test Page (/content/project/test-page), where Parent XF is being rendered via 'Experience Fragment' component.
Now, in Parent XF, the condition to render Child XF is checkbox controlled. And the component used in Parent XF is a react-based component, which will make a simple GET request to Child XF path and render the response HTML on the page. This is leading to the component inside Child XF consider the Parent XF as it's current page. As in, injecting current page in the inner-most component is giving path as '/content/experience-fragment/project/child-xf' instead of '/content/project/test-page'.
We have another use-case, involving Building Blocks, which is working out well for us in fetching current path details. Not sure, what went wrong in the above implementation.
Any leads in debugging the issue is appreciated. Thanks!
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Try below snippet.
String pagePath = request.getPathInfo().replace(".html", "");
Resource pageResource = resourceResolver.getResource(pagePath);
Hi @cmanoha1 ,
If you are not able to access the current page path in HTL then try to get it through your custom logic in model class.
Then use this model class in sightly to retrieve the current Page path.
Thanks
Tarun
Hi @TarunKumar
We have the same implementation. Getting the Page currentPage in sling model. We're getting XF path instead of current actual page path.
Try below snippet.
String pagePath = request.getPathInfo().replace(".html", "");
Resource pageResource = resourceResolver.getResource(pagePath);
this is also giving xf path itself
Views
Replies
Total Likes
Hi @cmanoha1
Were the user suggestions helpful? Let us know if more details are needed or mark the answer as correct. If you found a solution independently, please share it with the community.
Views
Likes
Replies
Views
Likes
Replies