Highlighted

How to total up first few elements in a for each loop of Sightly? | AEM Community Blog Seeding

kautuk_sahni

Community Manager

26-05-2020

BlogImage.jpg

How to total up first few elements in a for each loop of Sightly? by howtoaem Blog

Abstract

How to add the first three elements of a for loop in sightly and show the value as Total. I have code as below

{{each(i, provision) provisionTypes}}

{{/each}}
What I want to do is that in the each for loop, I want to display to the total of the first three elements... Not sure how to?

Best How To:
I don't think that is possible in Sightly. It is meant to be only for presentation purposes. it even lacks arithmetic operations, so you cannot really add numbers with it. You'll have to do it in the backend. You can use the WCMUse API (in it's java or javascript forms) to add some logic to your component

Read Full Blog

How to total up first few elements in a for each loop of Sightly?

Q&A

Please use this thread to ask the related questions.

AEM AEMEBlogSeeding Experience Manager