On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Thanks again. Glad I have back getPage, but my original question remains open:

    There's a &where property too in my call, working well. In case there are no items matching the criteria,
    the output of [[+itemsTotal]] is empty, not 0.
    Type casting did not help, and Output filters are not working.
    What else could I try?
    • this is strange, because I get 0, if there are no results.
      Can you test, what you get with that, what I posted earlier?

      [[!getPage?
      &element=`migxLoopCollection`
      &classname=`modResource`
      &limit=`20`
      &totalVar=`itemsTotal`
      &tpl=`@CODE:[[+pagetitle]]<br>`
      &where=`{"parent":"99999"}`
      ]]
       
      [[+itemsTotal]]


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
      • Tried it: The output is empty, not 0.
        • there must be something else wrong, because

          xPDO::getCount(), which is used internally, does allways return an integer, not an empty string.

          you can try to change the &totalVar to something different

          you can try, if you get something with:

          [[+itemsTotal:is=`0`:then=`null`:else=`[[+itemsTotal]]`]]


          (perhaps the value is 0, but gets removed somehow)

            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
          • I tried various snippets similar to yours in Reply #2, to no avail.
            For $modx->getPlaceholder($placeholder) I always get an empty string.
            It seems that the &totalVar property is not handled like other properties.
            • Tried this:
              [[+itemsTotal:is=`0`:then=`null`:else=`[[+itemsTotal]]`]]
              The output is, in any case, the same as for
              [[+itemsTotal]]
              • i'm having this same problem every time there are no elements for the totalVar to count it doesn't output anything and none of the solutions that were put forth have worked