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
BedrockMission!

Learn More

View all

Sign in to view all badges

Trying to iterate in sightly

Avatar

Avatar
Validate 1
Level 2
lovepreetk75597
Level 2

Likes

3 likes

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile

Avatar
Validate 1
Level 2
lovepreetk75597
Level 2

Likes

3 likes

Total Posts

24 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 5
Ignite 3
Ignite 1
Give Back 3
View profile
lovepreetk75597
Level 2

09-05-2019

Hi,

I have one requirement where i have one multivalue field and based on that am trying to iterate by using data-sly-list.

My filed is dc:title which i have made multifield and thrn iterating like below:

<sly data-sly-list="${asset.properties['dc:title']}">

// my code

</sly>

Now lets say i have values abc, xyz and i want in 1st iteration only abc should come but value is coming in coma-separated form as abc,xyz.

How can i handle this??

Thanks in advance,

Regards,

Lovepreet

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile

Avatar
Establish
MVP
Ravi_Pampana
MVP

Likes

190 likes

Total Posts

239 posts

Correct Reply

74 solutions
Top badges earned
Establish
Contributor
Shape 1
Ignite 5
Ignite 3
View profile
Ravi_Pampana
MVP

09-05-2019

Hi,

It will best if you add sling models to your multifield resource (component) and iterate like below

<div

    data-sly-use.multiItems="aem.community.mf.core.models.Multifield">

    <div data-sly-list.head="${multiItems.products.listChildren}">

       <div style="height:250px;"><img src=${head.pathbr} height=200 width=270 style="padding:4px"/><h2>${head.product}</h2>

           <p>${head.desc}</p>

     </div>

   </div>

Above example provide by smacdonald2008​ gives you idea about sling models

Also refer https://blogs.perficientdigital.com/2018/08/24/using-sling-models-with-nested-composite-mulitifields...

Hope this helps !

Answers (2)

Answers (2)

Avatar

Avatar
Give Back 5
Level 4
praveenjain
Level 4

Likes

37 likes

Total Posts

36 posts

Correct Reply

10 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Boost 5
View profile

Avatar
Give Back 5
Level 4
praveenjain
Level 4

Likes

37 likes

Total Posts

36 posts

Correct Reply

10 solutions
Top badges earned
Give Back 5
Give Back 3
Give Back
Ignite 1
Boost 5
View profile
praveenjain
Level 4

09-05-2019

This will happen when value of dc:title multi-field property is saved as string in node as comma separated.

Please check, and update multi-field logic in dialog to save as String array. With string array it should work fine.

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

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

09-05-2019

This article shows you exactly how to interate through a collection (Multifield) using HTL:

Adobe Experience Manager Help | Creating a HTL Repeating Data Set 6.4 Component that uses Sling Mode...