Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn more

View all

Sign in to view all badges

SOLVED

What is the use of TemplatedContainer (data-sly-use.templatedContainer)

tushaar_srivastava
Level 4
Level 4

I tried to find an Adobe post related to TemplatedContainer.

Could you please help me what is TemplatedContainer, as we have to use this in Editable Template.

 

I have seen many code snippet like below: 

<sly data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"
data-sly-repeat.child="${templatedContainer.structureResources}"
data-sly-resource="${child.path @ resourceType=child.resourceType, decorationTagName='div'}"/>

 But don't know what is this and what and where is the use of TemplatedContainer

 

@kautuk_sahni  @Arun_Patidar 

AEM6.3.0 Editable templates TemplatedContainer
1 Accepted Solution
Veena_Vikram
Correct answer by
Community Advisor
Community Advisor

@tushaar_srivastava This is what I understand about this API. Since there is not much documentation on how the API works and what each method actually does, I did some research. So basically the api helps to resolve your templates , structure node. Lets take an example of the WKND pages ( the sample project )

So lets say I have a page best-tacos-in-the-city.html This page is defined using article-page-template . Now for the article page template , you have a structure node , where the structure of your template is defined and the node structure for the same would be as below

 
 

wknd.JPG  

TemplatedContainer API helps you to fetch these structure nodes or to check if the template has a structured content and its inherited methods from WCMPojo helps with a lot of other page and resource methods. Please check https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/co...

 

Coming back to the structuredResource , 

<sly data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"
data-sly-list.child="${templatedContainer.structureResources}">

If you try to print and check ${child.path} , you can see that it resolves to the structure content node, in this case /conf/wknd/settings/wcm/templates/article-page-template/structure/jcr:content/root

 

 

templated-container.JPG

 

In line 18 of the above body.html , when the child.path is included as a resource , you are actually including the "/conf/wknd/settings/wcm/templates/article-page-template/structure/jcr:content/root" node as a resource and that way all the below resources of the root node will get included to your page. 

 

Hope this helps. Let me know if you have any more questions.

 

Thanks

Veena

View solution in original post

7 Replies
BrianKasingli
Community Advisor
Community Advisor
com.day.cq.wcm.foundation.TemplatedContainer extends WCMUsePojo

This looks like a snippet from the body.html within the WCM Core Page V2 Component. It's an AEM component with a one to one releationship with a WCMUsePojo Class. The WCmUsePojo Class returns a "structureResources" property to the Sightly HTL script for its consumption. The "structureResources" is a List<Resource> Object, and the data-sly-repeat, expression to repeat the content of the element for each item of the provided object is utilised.

For each repeat, data-sly-resource, is called which Includes a rendered resource to the page with a decorationTagName "div".

You can imagine the body.html takes all the resources listed in the /content/my-site/page/jcr:content/*, and attempts to server-side render all the resources to the resulting page.

 

I hope this helps.

Veena_Vikram
Correct answer by
Community Advisor
Community Advisor

@tushaar_srivastava This is what I understand about this API. Since there is not much documentation on how the API works and what each method actually does, I did some research. So basically the api helps to resolve your templates , structure node. Lets take an example of the WKND pages ( the sample project )

So lets say I have a page best-tacos-in-the-city.html This page is defined using article-page-template . Now for the article page template , you have a structure node , where the structure of your template is defined and the node structure for the same would be as below

 
 

wknd.JPG  

TemplatedContainer API helps you to fetch these structure nodes or to check if the template has a structured content and its inherited methods from WCMPojo helps with a lot of other page and resource methods. Please check https://helpx.adobe.com/experience-manager/6-5/sites/developing/using/reference-materials/javadoc/co...

 

Coming back to the structuredResource , 

<sly data-sly-use.templatedContainer="com.day.cq.wcm.foundation.TemplatedContainer"
data-sly-list.child="${templatedContainer.structureResources}">

If you try to print and check ${child.path} , you can see that it resolves to the structure content node, in this case /conf/wknd/settings/wcm/templates/article-page-template/structure/jcr:content/root

 

 

templated-container.JPG

 

In line 18 of the above body.html , when the child.path is included as a resource , you are actually including the "/conf/wknd/settings/wcm/templates/article-page-template/structure/jcr:content/root" node as a resource and that way all the below resources of the root node will get included to your page. 

 

Hope this helps. Let me know if you have any more questions.

 

Thanks

Veena

View solution in original post

_SumitSinghal
Level 4
Level 4

Hi Veena,

 

This article is really awesome and it explains everything about templateContainer in details. I have one query in case if the cq:template path on the jcr:content node of the page is missing or having path which is not present or removed in that case what would happen .

 

Will the page render or it will hang and page will keep on loading. Do you see such use case?

Veena_Vikram
Community Advisor
Community Advisor
@_SumitSinghal I just saw your question. When such a scenario happens, it will error. Page might not be loaded as per my understanding