We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16633
    • 116 Posts
    I am using the latest version of Revo and getResources. I am pulling all child pages and need to list the total resources found. Is there a way to do this with getResources?
      --
      Landon Poburan
      Web Designer and Developer

      http://www.categorycode.ca
      http://www.landonp.com
      • 3749
      • 24,544 Posts
      You could try [[+idx]], which is updated for every resource pulled.  Otherwise, a custom snippet something like this:

      [[!getNumber? &parentId=`12`]]


      <?php
      /* getNumber snippet */
      $return = $modx->getCount('modResource', array('parent'=>$parentId,'published'=>'1', 'deleted'=>'0'));
      
      [ed. note: BobRay last edited this post 13 years, 6 months ago.]
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 22303 MODX Staff
        • 10,725 Posts
        getResources already sets a placeholder (key indicated via &totalVar=`nameofplaceholdertouse`, default is `total`) with the total number of records it retrieved. So just use [[+total]]. No need for anything extra.
          • 16633
          • 116 Posts
          Quote from: OpenGeek at Oct 28, 2010, 05:13 PM

          getResources already sets a placeholder (key indicated via &totalVar=`nameofplaceholdertouse`, default is `total`) with the total number of records it retrieved. So just use [[+total]]. No need for anything extra.

          Thanks I will try this tonight. That should really be in the documentation for it.
            --
            Landon Poburan
            Web Designer and Developer

            http://www.categorycode.ca
            http://www.landonp.com
            • 16633
            • 116 Posts
            Quote from: OpenGeek at Oct 28, 2010, 05:13 PM

            getResources already sets a placeholder (key indicated via &totalVar=`nameofplaceholdertouse`, default is `total`) with the total number of records it retrieved. So just use [[+total]]. No need for anything extra.

            Here is the code I am using:
            [[!getResources? &parents=`43` &limit=`` &tpl=`NominationListTpl`]]
            [[+total]]

            There is only 1 resource and it is display but the total displays: 5
              --
              Landon Poburan
              Web Designer and Developer

              http://www.categorycode.ca
              http://www.landonp.com
              • 16633
              • 116 Posts
              Neverming. I specified a placeholder and it works now.
                --
                Landon Poburan
                Web Designer and Developer

                http://www.categorycode.ca
                http://www.landonp.com
                • 3749
                • 24,544 Posts
                Quote from: OpenGeek at Oct 28, 2010, 05:13 PM

                getResources already sets a placeholder (key indicated via &totalVar=`nameofplaceholdertouse`, default is `total`) with the total number of records it retrieved. So just use [[+total]]. No need for anything extra.

                Should probably mention that here: http://rtfm.modx.com/display/ADDON/getResources wink
                  Did I help you? Buy me a beer
                  Get my Book: MODX:The Official Guide
                  MODX info for everyone: http://bobsguides.com/modx.html
                  My MODX Extras
                  Bob's Guides is now hosted at A2 MODX Hosting
                  • 16633
                  • 116 Posts
                  Quote from: BobRay at Oct 28, 2010, 09:03 PM

                  Quote from: OpenGeek at Oct 28, 2010, 05:13 PM

                  getResources already sets a placeholder (key indicated via &totalVar=`nameofplaceholdertouse`, default is `total`) with the total number of records it retrieved. So just use [[+total]]. No need for anything extra.

                  Should probably mention that here: http://rtfm.modx.com/display/ADDON/getResources wink

                  Agreed. The MODx documentation could use a little work. It is good but things like that shouldn’t be missing (I guess thats were we come in!). But luckily the community awesome, I just started using the Forum and never realized how helpful people are.
                    --
                    Landon Poburan
                    Web Designer and Developer

                    http://www.categorycode.ca
                    http://www.landonp.com
                    • 22303 MODX Staff
                    • 10,725 Posts
                    I added totalVar to the Other Properties section in the documentation for getResources, and clarified my previous response. Note that this is the total number of records that would be selected, not taking into account the limit/offset properties that are specified. This is actually a feature to make getResources compatible with getPage, as getPage needs to know the total number of records to page over, not just how many were returned. Of course, in the case of wanting the actual total when using the limit property, since you are setting the limit property for the call anyway, I don’t think that is really a problem. grin
                      • 33608
                      • 27 Posts
                      That is nice that it returns the total number of the results that would be selected, but I have an interesting situation where it would be nice to have the total of the results that are being returned.

                      I have some tvFilters in place and restricting the limit of the returned result, but the total stays the same, so now it’s inaccurate. I have 4 resources, and right now my results list out and above them I have "Showing 1-4" where 4 is generated by the [[+total]] placeholder. Then I filter them, and 2 or 3 results get shown, but the [[+total]] placeholder still outputs 4. Any ideas?