Expand my Community achievements bar.

SOLVED

SDI with Dynamic Template

Avatar

Community Advisor

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?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.



Arun Patidar

View solution in original post

6 Replies

Avatar

Community Advisor

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.



Arun Patidar

Avatar

Community Advisor

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

Avatar

Community Advisor

Hi @Sady_Rifat 

Can you please check if it work without SDI?

 



Arun Patidar

Avatar

Community Advisor

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

Avatar

Correct answer by
Community Advisor

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.



Arun Patidar

Avatar

Level 7

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.