Find out embedded components within the main component. | Community
Skip to main content
cquser1
Level 7
February 14, 2017
Solved

Find out embedded components within the main component.

  • February 14, 2017
  • 1 reply
  • 882 views

Hi All,

I have a column control that appears on the page [for now say at one location, as below]. 

/content/xxx/sample/jcr:content/par/columncontrol.

If I placecomponents in only 1st or both 1st and 2nd column[and so on] the structure changes to /content/xxx/sample/jcr:content/par/columncontrol/par0, /content/xxx/sample/jcr:content/par/columncontrol/par0 and  /content/xxx/sample/jcr:content/par/columncontrol/par1 respectively and so on.

Basically, I need to check whether any components[may be 1 or 2 or whatever] are added to my column control component and based on that in my columncontrol html, 

<div class="column-control blah blah ''}">

</div>

I have to put a condition [probably data-sly-test] to this main div, so that this div is not included if no components are added inside column control component.

Any pointers/reference code on how to go about this will be helpful.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by edubey

1. Write a simple WCMUsePojo class which reads the child nodes of column control. 

2.  If you par0 or par1, you should be able to see resourceType property in them which can help you to know which component is that.

Example HTML for column control component. Below code is somewhat similar but not accurate.

<div data-sly-use.childNodes="com.project.ColumnControlUse"> <div data-sly-test="${childNodes.isExists}"> </div> </div>

1 reply

edubey
edubeyAccepted solution
Level 10
February 15, 2017

1. Write a simple WCMUsePojo class which reads the child nodes of column control. 

2.  If you par0 or par1, you should be able to see resourceType property in them which can help you to know which component is that.

Example HTML for column control component. Below code is somewhat similar but not accurate.

<div data-sly-use.childNodes="com.project.ColumnControlUse"> <div data-sly-test="${childNodes.isExists}"> </div> </div>