extract other child component's properties in current child component among the list of child nodes on AEM Page using Sightly alone (no sightly model in java)

Avatar

Avatar

psrpjayaem

Avatar

psrpjayaem

psrpjayaem

03-09-2020

extract other child component's properties in current child component among the list of child nodes on AEM Page using Sightly alone (no sightly model in java)
For example, the aem page named test is created with the header, hero and footer components.
From the footer's HTL, there is a need to find the header component present in the list of child nodes of AEM Page named 'test' and if header component is present, then extract the properties of header component.
psrpjayaem_0-1599146761433.png

 

View Entire Topic

Avatar

Avatar

Nupur_Jain

MVP

Avatar

Nupur_Jain

MVP

Nupur_Jain
MVP

03-09-2020

Hi @psrpjayaem 

 

With HTL, you can extract first the parent of the current component that is footer. Then you can extract header resource from parent resource like this:

 

<div data-sly-test.headerResource="${resource.parent.header}">
<!-- Extract properties if header resource exists with ${headerResource.properties.property1}-->
</div>


OR-----------------------------------------

<div data-sly-list="${resource.parent.listChildren}">
    <div data-sly-test.headerResource="${item.name == 'header'}">
        <!-- Extract properties if header resource exists with ${headerResource.properties.property1}-->
    </div>
</div>

 

 

Here resource represents the current resource. resource.parent basically call getParent method of resource api and provide you with parent resource.

 

you can both the options and whatever fits your usecase better, you can try.

 

Hope it Helps!

Thanks