SDI with Dynamic Template | Adobe Higher Education
Skip to main content
Sady_Rifat
Community Advisor
Community Advisor
January 30, 2025
Répondu

SDI with Dynamic Template

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?

Ce sujet a été fermé aux réponses.
Meilleure réponse par arunpatidar

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


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.

2 commentaires

arunpatidar
Community Advisor
Community Advisor
January 30, 2025

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
Sady_Rifat
Community Advisor
Community Advisor
January 30, 2025

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

arunpatidar
Community Advisor
Community Advisor
January 30, 2025

Hi @sady_rifat 

Can you please check if it work without SDI?

 

Arun Patidar
AmitVishwakarma
Community Advisor
Community Advisor
February 2, 2025

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.