Expand my Community achievements bar.

SOLVED

Sightly List first element

Avatar

Level 4

Hello,

How do we get the first element from data-sly-list ?

desktop_exl_promo_600x100_weempoweryou.png

1 Accepted Solution

Avatar

Correct answer by
Administrator

Hi

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

Please have a look at this documentation:- 

Link:- http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-1/

// Sample6.html

Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/sightly/block-statements.html

//

The following default variables are available within the scope of the list:

item: The current item in the iteration.

itemList: Object holding the following properties:

index: zero-based counter (0..length-1).

count: one-based counter (1..length).

first: true if the current item is the first item.

middle: true if the current item is neither the first nor the last item.

last: true if the current item is the last item.

odd: true if index is odd.

even: true if index is even.

 

Sightly Specification:- https://github.com/Adobe-Marketing-Cloud/sightly-spec/blob/master/SPECIFICATION.md#226-list

 

For Looping to the count:-

Loop with fixed number of items

<ul data-sly-list="${ [1,2,3,4] }">
<li>${item}</li>
</ul>

 

I hope this will help you,

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

View solution in original post

2 Replies

Avatar

Correct answer by
Administrator

Hi

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

Please have a look at this documentation:- 

Link:- http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-1/

// Sample6.html

Link:- https://docs.adobe.com/docs/en/aem/6-1/develop/sightly/block-statements.html

//

The following default variables are available within the scope of the list:

item: The current item in the iteration.

itemList: Object holding the following properties:

index: zero-based counter (0..length-1).

count: one-based counter (1..length).

first: true if the current item is the first item.

middle: true if the current item is neither the first nor the last item.

last: true if the current item is the last item.

odd: true if index is odd.

even: true if index is even.

 

Sightly Specification:- https://github.com/Adobe-Marketing-Cloud/sightly-spec/blob/master/SPECIFICATION.md#226-list

 

For Looping to the count:-

Loop with fixed number of items

<ul data-sly-list="${ [1,2,3,4] }">
<li>${item}</li>
</ul>

 

I hope this will help you,

Thanks and Regards

Kautuk Sahni



Kautuk Sahni