Expand my Community achievements bar.

SOLVED

Find out embedded components within the main component.

Avatar

Level 8

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.

1 Accepted Solution

Avatar

Correct answer by
Level 10

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>

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

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>