<?php
$id = $modx->resource->get('id');
$c = $modx->newQuery('redasNewsPackage');
$c->where(array('resource_id' => $id));
$c->sortby('createdon','DESC');
$total = $modx->getCount('redasNewsPackage',$c);
$totalVar = $modx->getOption('totalVar', $scriptProperties, 'total');
$modx->setPlaceholder($totalVar,$total);
$c->limit($limit,$offset);
$collection = $modx->getCollection('redasNewsPackage',$c);
foreach($collection as $item) {
$vars = $item->toArray();
$out[] = $modx->getChunk($tpl, $vars);
}
return implode("\n", $out);<div class="article-results">[[!getPage? &element=`TestPagination` &tpl=`articleResults` &limit=`20` &pageLimit=`2`]]</div> <div class="paging"><span class="pages">Page [[+page]] of [[+pageCount]]</span> [[+page.nav]]</div>
<div>
<a href="[[+file]]">[[+title]]</a>
</div>
This question has been answered by Bruno17. See the first response.
[[!getPage?
&element=`migxLoopCollection`
&packageName=`yourPackage`
&classname=`yourClass`
&tpl=`yourTpl`
&limit=`20`
&where=`{"resource_id":"[[*id]]"}`
&sortConfig=`[{"sortby":"createdon","sortdir":"DESC"}]`
]]