Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

How to limit number of times list gets iterated in sightly

Avatar

Level 3

<sly data-sly-list=" ">

<h1> Hello World </h1>

</sly>

 

How to iterate through the loop only 4 times? 

Thanks in advance!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Please refer this 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-use-an-integer-valu...

 

If you are dealing with dynamic value then you can use below code -

<ul data-sly-list="${currentPage.listChildren @ begin = 0, end = 3}">
<li>${item.title}</li>
</ul>

 

[

<!--/* if you want to first 5 elements of the list */-->

<ul data-sly-list="${currentPage.listChildren @ begin = 0, end = 4}"> <li>${item.title}</li> </ul>

<!--/* if you want to see from 5th to 10th element */-->

<div data-sly-repeat="${currentPage.listChildren @ begin = 4, end = 9}"> <div>${item.title}</div> </div>

]

https://www.myareapage.com/3-new-features-of-htl-in-aem-6-5/

 

Hope these will help you.

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

Please refer this 

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/how-to-use-an-integer-valu...

 

If you are dealing with dynamic value then you can use below code -

<ul data-sly-list="${currentPage.listChildren @ begin = 0, end = 3}">
<li>${item.title}</li>
</ul>

 

[

<!--/* if you want to first 5 elements of the list */-->

<ul data-sly-list="${currentPage.listChildren @ begin = 0, end = 4}"> <li>${item.title}</li> </ul>

<!--/* if you want to see from 5th to 10th element */-->

<div data-sly-repeat="${currentPage.listChildren @ begin = 4, end = 9}"> <div>${item.title}</div> </div>

]

https://www.myareapage.com/3-new-features-of-htl-in-aem-6-5/

 

Hope these will help you.