We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    well, this is only one item. Then 1 is the correct result.
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 38537
      • 34 Posts
      Yes, thats right. But on my next page, I have no data sets and it's return also the number 1
        • 38537
        • 34 Posts
        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
          • 4172
          • 5,888 Posts
          try this:
          <?php
          $items = $modx->fromJSON($input);
          
          return is_array($items) ? count($items) : 0 ;
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 4172
            • 5,888 Posts
            try this:
            <?php
            $items = $modx->fromJSON($input);
            
            return is_array($items) ? count($items) : 0 ;
              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 37984
              • 215 Posts
              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]]
                Jesse Couch
                MODX Aficionado, Front-End Designer & Developer
                http://www.designcouch.com