If you want to try it with MIGX.
This scenario did work for me:
<table>
[[getImageList?
&tpl=`addvalues`
&value=`[
{"MIGX_id":"1","num":"10"},
{"MIGX_id":"2","num":"5"},
{"MIGX_id":"3","num":"6"},
{"MIGX_id":"4","num":"4"}
]`]]
<tr><td>Result</td> <td>[[+result_of_num]]</td></tr>
</table>
chunk addvalues:
[[addvalue? &idx=`[[+idx]]` &value=`[[+num]]`&placeholder=`result_of_num`]]
<tr><td>[[+idx]]</td> <td>[[+num]]</td></tr>
snippet addvalue:
$oldvalue = $modx->getPlaceholder($placeholder);
$value = $modx->getOption('value',$scriptProperties,0);
$newvalue = empty($oldvalue)? $value : $oldvalue + $value;
$modx->setPlaceholder($placeholder,$newvalue);
return $output=='result' ? $newvalue : '';
So If you would create a MIGX-TV which returns this output:
[{"MIGX_id":"1","num":"10"},
{"MIGX_id":"2","num":"5"},
{"MIGX_id":"3","num":"6"},
{"MIGX_id":"4","num":"4"}]
it should work.
[ed. note: Bruno17 last edited this post 14 years, 6 months ago.]