List Children in Sightly

Avatar

Avatar

rk39193348

Avatar

rk39193348

rk39193348

25-01-2017

Hi,
I am using the below code to print list children items on page, but it's not working. Can anyone please suggest how to achieve this?

<ul data-sly-list.child="${currentPage.listChildren}">

 entering <li>${child.title}</li>
</ul>

Regards
 

View Entire Topic

Avatar

Avatar

huzaifaha985211

Avatar

huzaifaha985211

huzaifaha985211

26-01-2017

One way to do it is to use a bundled Java Class where you can put your logic and then return the result you want into your componentName.html.  

Here is an example from https://docs.adobe.com/docs/en/htl/docs/use-api/java.html

 

/apps/my-example/component/info/Info.java
package org.example.app.components;
  
import com.adobe.cq.sightly.WCMUse;
  
public class Info extends WCMUse {
    ...
}
 

Code samples are intended for illustration purposes only.

and, the data-sly-use statement must reference the fully qualified class name, as opposed to just the local class name:

/apps/my-example/component/info/info.html
<div data-sly-use.info="org.example.app.components.info.Info">
  <h1>${info.title}</h1>
  <p>${info.description}</p>
</div>