Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Sorting Properties

Avatar

Level 5

I have a component with 3 RTE, and they are stored as 

{
"jcr:primaryType": "nt:unstructured",
"header": "bg",
"jcr:lastModifiedBy": "admin",
"C_background_reasons-to-buy": "<p>Reasons to buy</p>\r\n",
"jcr:lastModified": "Wed Apr 24 2024 10:15:09 GMT+0200",
"sling:resourceType": "org/components/somecomponent",
"textIsRich": [
"true",
"true"
"true"
],
"B_background_random-proposition": "<p>Random proposition</p>\r\n",
"A_background_collection-concept-story": "<p>Collection Concept Story</p>\r\n"
}

I am trying to read 3 properties (starting with A_, B_ & C_ ) and I use sightly to iterate and have some condition..

<sly data-sly-list.property="${properties}">
Issue - It does not maintain the order they were authored in. E.g. - I want A_ to be displayed first then B_ and then C_ . Is there a out of the box property I can use to do some kind of sorting or make sure the fields are read in order ?
 
Ps- A_ , B_ are not actual names, so not looking for alphabetically sorting but open to change.
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @anupampat ,

 

As per my knowledge there is no such property/feature available on Sightly.

To achieve your scenario, create a sling model for the component and try to make the sorting be done in the backend.

View solution in original post

4 Replies

Avatar

Correct answer by
Community Advisor

Hi @anupampat ,

 

As per my knowledge there is no such property/feature available on Sightly.

To achieve your scenario, create a sling model for the component and try to make the sorting be done in the backend.

Avatar

Community Advisor

I would recommend to use Multifield if your requirement permits. Otherwise, you can create a list and add items as the order you want to the Sling Model as @sravs suggested.

Avatar

Community Advisor

Hi @anupampat 

I think if you use sling model instead of calling properties directly to sightly, you can resolve the resource and get the valueMap of the resource. Then you will get all the values in a sorted order by the property names. And then you can return this map. You can give a try with this approach.

 

Thanks,

Asif Ahmed

Avatar

Administrator

@anupampat Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni