$total = $modx->getCount('myCollections',$c);//<== first getCount for totalVar
$totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
$modx->setPlaceholder($totalVar,$total);
$limit = $modx->getOption('limit',$scriptProperties,5);
$offset = $modx->getOption('offset',$scriptProperties,0);
$c->limit($limit,$offset);
$c->sortby($sortby,$dir);
$pagetotal = $modx->getCount('myCollections',$c);// <== this call equals the same number as the first getCount call above on the first page, and zero on subsequent pages.
$modx->setPlaceholder('pagecount',$pagetotal);
$all_xnippets = $modx->getCollection('myCollections',$c);
This question has been answered by Bruno17. See the first response.
$pagetotal = 0;
if ($all_xnippets = $modx->getCollection('myCollections',$c)){
$pagetotal = count($all_xsnippets);
}why not
$pagetotal = 0; if ($all_xnippets = $modx->getCollection('myCollections',$c)){ $pagetotal = count($all_xsnippets); }
Quote from: Bruno17 at Dec 06, 2015, 11:40 AMwhy not
$pagetotal = 0; if ($all_xnippets = $modx->getCollection('myCollections',$c)){ $pagetotal = count($all_xsnippets); }
Yeah Bruno, that worked. I guess I'm just curious why my method didn't after applying the criteria.
Thx!
Do Not Cachehttps://rtfm.modx.com/extras/revo/getpage#getPage-Usage
The getPage snippet must never be called cacheable on a Resource that is cacheable. It is best to always call getPage with the non-cacheable token, !, while still caching the rest of the Resource output. The same rule applies for the placeholder represented by the pageNavVar property (page.nav by default) so that its output is not cached into the cacheable page content.
getPage has to be called uncached anyway.
Do Not Cachehttps://rtfm.modx.com/extras/revo/getpage#getPage-Usage
The getPage snippet must never be called cacheable on a Resource that is cacheable. It is best to always call getPage with the non-cacheable token, !, while still caching the rest of the Resource output. The same rule applies for the placeholder represented by the pageNavVar property (page.nav by default) so that its output is not cached into the cacheable page content.
Quote from: sottwell at Dec 06, 2015, 05:38 PMgetPage has to be called uncached anyway.
Do Not Cachehttps://rtfm.modx.com/extras/revo/getpage#getPage-Usage
The getPage snippet must never be called cacheable on a Resource that is cacheable. It is best to always call getPage with the non-cacheable token, !, while still caching the rest of the Resource output. The same rule applies for the placeholder represented by the pageNavVar property (page.nav by default) so that its output is not cached into the cacheable page content.
I was referring to the caching of the snippet content being cached. Getpage itself is called uncached. Setting the caching in getPage properties as I understood from https://rtfm.modx.com/extras/revo/getpage#getPage-CachingProperties caches the result set for the page. That setting causes my counts not to render. Even setting the placeholder to uncached doesn't work [[!+count]]. One would assume that the need to call the [[+page.nav]] uncached also (as stated above) would apply to other placeholders as well. But alas it does not.
Quote from: harveyev at Dec 07, 2015, 07:07 AMQuote from: sottwell at Dec 06, 2015, 05:38 PMgetPage has to be called uncached anyway.
Do Not Cachehttps://rtfm.modx.com/extras/revo/getpage#getPage-Usage
The getPage snippet must never be called cacheable on a Resource that is cacheable. It is best to always call getPage with the non-cacheable token, !, while still caching the rest of the Resource output. The same rule applies for the placeholder represented by the pageNavVar property (page.nav by default) so that its output is not cached into the cacheable page content.
I was referring to the caching of the snippet content being cached. Getpage itself is called uncached. Setting the caching in getPage properties as I understood from https://rtfm.modx.com/extras/revo/getpage#getPage-CachingProperties caches the result set for the page. That setting causes my counts not to render. Even setting the placeholder to uncached doesn't work [[!+count]]. One would assume that the need to call the [[+page.nav]] uncached also (as stated above) would apply to other placeholders as well. But alas it does not.
If getCache uses cached output, your snippet isn't executed and the placeholder isn't set.