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?
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.]
-
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.
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.
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
Neverming. I specified a placeholder and it works now.
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
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 
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.
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?