well, this is only one item. Then 1 is the correct result.
Yes, thats right. But on my next page, I have no data sets and it's return also the number 1
Ok, I tested something.
When I have no data set and/or one data set, then i became the value 1.
And if there more than 1 data set I became the correct value.
Little bit strange, or? (:
discuss.answer
try this:
<?php
$items = $modx->fromJSON($input);
return is_array($items) ? count($items) : 0 ;
try this:
<?php
$items = $modx->fromJSON($input);
return is_array($items) ? count($items) : 0 ;
I'm confused as to why everyone is writing custom snippets - this is built into MIGX.
In your GetImageList tpl chunk (or @code) simply use the placeholder [[+total]] to count the number of datasets. You can even use the placeholder [[+idx]] to output the number each dataset is, within the total. For example:
Slide 1 of 5
would be created using this (assuming that there are 5 slides total):
Slide [[+idx]] of [[+total]]