Hello,
I have a component that is included in SDI config with nocache.
when I authored the component on the page, it worked as expected.
but when the component is authored in template structure then it has some problems
In my component model, I have this,
@ScriptVariable
private Page currentPage;
it becomes null, and when I try to debug with
request.getPathInfo()
// Result: /content/myproject/global/conf/myproject/settings/wcm/templates/product-page/structure/_jcr_content/head/columncontrol/col_1/tabs/item_1725959732966/col_1/accessories_1748107095.nocache.html/myproject/base/components/product-details/accessories/v1/accessories
In HTML markup,
<div class="accessories"><!-- SDI include (path: /conf/myproject/settings/wcm/templates/product-page/structure/_jcr_content/head/columncontrol/col_1/tabs/item_1725959732966/col_1/accessories_1748107095.nocache.html/myproject/base/components/product-details/accessories/v1/accessories, resourceType: myproject/base/components/product-details/accessories/v1/accessories) --> | |
So my requirement is how to get the Page from it?
Solved! Go to Solution.
Views
Replies
Total Likes
Hi @Sady_Rifat
I think this could be the limitation with SDI, because the fragment is generated independently from /conf and dispatcher prepared the consolidate output, so if you use SDI with templated component, it may not work.
Hi @Sady_Rifat
Which page are you expecting when authoring component in the template? If you are expecting the template path should return then it won't be because template node is type of "cq:Template"
@ScriptVariable
private Page currentPage;
Probability you need to write a fallback logic just for a template use case.
Actually, I am expecting the current page path. The actual page where the component belongs.
https://mysite.com/en/products.html -> /content/myproject/us/en/product
Views
Replies
Total Likes
yes, I checked with both, without SDI it's working, if I enable SDI and the component is on the page parsys not from the template structure then it works also.
Only misbehave when it authored on page template structure and then the live page is load
Views
Replies
Total Likes
Hi @Sady_Rifat
I think this could be the limitation with SDI, because the fragment is generated independently from /conf and dispatcher prepared the consolidate output, so if you use SDI with templated component, it may not work.
The issue is likely due to SDI treating templated components differently, causing the currentPage to be null. You can try:
1. Fallback Logic: Manually resolve the page from request.getPathInfo() when currentPage is null.
2. Limitations with SDI: SDI generates fragments from /conf, which may not properly handle the page context in templated components.