We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24629
    • 370 Posts
    Hi all,
    I've setup Migx to hold several text entries i use a snippet to pick 1 entrie random.
    I have this in a snippet to get the entries
    $strJSON = $modx->resource->getTVValue('MyMIGXtv');
    $arrJSON = $modx->fromJSON($strJSON);
    $amt = count($arrJSON);


    even when nothing has been filled in, in the TV (so no Items in the MIGX) $amt returns 1
    why is that? Am i doing something wrong?
      • 4172
      • 5,888 Posts
      may be, you should check, if it is an array at all, before counting:

      $amt = is_array($arrJSON) ? count($arrJSON) : 0;
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 24629
        • 370 Posts
        Hi Bruno,
        Yes that works. So this had nothing to do with MIGX.
        fromJSON($json) returns not an array when the $json is empty

        tnx for the help