- Issue created by @bigtomfelix
- 🇩🇪Germany jurgenhaas Gottmadingen
You would initialize a token by setting its value to `0`, then loop through all the paragraph entities and use the math tamper plugin to add the value of each paragraph to that initial token. Once you went through all of them, that tokens contains the sum of all of their individual values.
- 🇮🇹Italy bigtomfelix
Thanks for the quick reply. The problem I have is that I don't know how to iterate through all the paragraph entities without knowing how many there are, it could be 1 or 2 or 3, depending on the node.
- 🇩🇪Germany jurgenhaas Gottmadingen
You can loop through the list of available items until none is left. An example of that can be found in the ECA Guide: https://ecaguide.org/library/use%20case/multi_value_field_loop/
- 🇮🇹Italy bigtomfelix
Thanks for the reply. I looked at the example given, but I still can't get what I'm looking for. I just can't.
basically the problem is this: I have a content type with a paragraph. inside the paragraph I have numeric values. in the node I have a sum value (empty) that should be filled with the sum of the values of the fields of the paragraph. Values that can be two or three or four, in short each node could have one or more instances of paragraph. I don't understand where the loop should intervene and how to recall the token value relating to the different paragraphs. If someone could help me it would be great. Thanks in advance. - 🇩🇪Germany jurgenhaas Gottmadingen
So, you get the field value from that node field, which contains the x number of paragraphs and stick that into a token. Just like in the example. Then, that token contains a list of paragraphs. Then you start the loop: as long as there is another paragraph in that list, you enter into the loop and take one paragraph off the list into another token. Then you take the numeric value from that paragraph and add it with tamper to the already existing value. Then you go back to the beginning of the loop. You do that, until the list of paragraphs is empty.
- 🇮🇹Italy bigtomfelix
I solved it thanks to your instructions. It took me a while because I actually realized that I hadn't been very precise in my question. Thanks again for your availability
Automatically closed - issue fixed for 2 weeks with no activity.