So I've used bits and pieces from all over the place to try and get this working. Here's what I have:
<?php
$c = $modx->newQuery('modResource');
$c->where(array(
'published' => 1,
'template' => 10,
));
$total = $modx->getCount('modResource',$c);
$totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
$modx->setPlaceholder($totalVar,$total);
$tpl = $modx->getOption('tpl', $scriptProperties, '');
$limit = $modx->getOption('limit',$scriptProperties,6);
$offset = $modx->getOption('offset',$scriptProperties,5);
$c->sortby('publishedon','DESC');
$c->limit($limit,$offset);
$collection = $modx->getCollection('modResource',$c);
foreach($collection as $item) {
$vars = $item->toArray();
$out[] = $modx->getChunk($tpl, $vars);
}
return implode("\n", $out);
If I call in a template like this:
[[!pagingTest? &limit=`8` &offset=`5` &tpl=`newsLandingOther`]]
I get exactly what I expect, minus the pagination. There are 7 items, and 2 appear here when I call it.
So next, I try to wrap getPage around it like this:
[[!getPage?
&elementClass=`modSnippet`
&element=`pagingTest`
&tpl=`newsLandingOther`
&pageVarKey=`page`
&totalVar=`total`
&limit=`4`
&offset=`5`
]]
Which, as previous issues with getPage I've run into ignores the offset I've set, even though the snippet definitely has the correct call. I must be doing something fundamentally stupid here because this:
http://www.markhamstra.com/modx-blog/2011/12/preparing-custom-snippets-for-getpage/ and
http://rtfm.modx.com/display/ADDON/getPage#getPage-OtherProperties suggest this should work.
Kind of a follow on from this topic:
https://forums.modx.com/thread/78109/articles-paging-and-getpage-are-ignoring-offset-in-parameters-list?page=2#dis-post-431004