I've set this up so that a main blog page displays an initial 3 posts, with tags when loaded fully.
[[!getResourcesTag?
&element=`getResources`
&elementClass=`modSnippet`
&tpl=`blog-item`
&tplFirst=`blog-item-featured`
&limit=`3`
&hideContainers=`1`
&parents=`5`
&tagKey=`blog-tags`
&includeTVs=`1`
&tvPrefix=``
]]
The initial 3 posts displayed are sorted by date order on the main landing page (most recent first) e.g. Article 1, Article 2 & Article 3.
On clicking a "more posts" button underneath the 3 posts that are displayed, infinite scroll pagination (which has been set-up) kicks in.
<button class="load-more" data-parent="5" data-current-page="1">More Posts</button>
But when clicking on More Posts - Article 3 (again) & Article 4 are returned - instead of Article 4 & Article 5.
$method = $modx->getOption('method', $scriptProperties, 'initial');
$limit = $modx->getOption('limit', $scriptProperties, 3);
$parent = $modx->getOption('parent', $scriptProperties);
$tpl = $modx->getOption('tpl', $scriptProperties);
$tplFirst = $modx->getOption('tplFirst', $scriptProperties);
$load = (int) $_GET['page'];
$offset = 0;
if($method == "initial") {
if($load != 0) {
$limit = $limit * $load;
}
} elseif($method == "pagination") {
$offset = $limit * ($load - 1);
}
$page = $modx->runSnippet('getResources', array(
'parents' => $parent,
'limit' => $limit,
'offset' => $offset,
'includeTVs' => '1',
'tvPrefix' => '',
'includeContent' => '1',
'tpl' => $tpl,
'tplFirst' => $tplFirst
));
I've played about with parameters & tried altering the code that deals with offset
but can't seem to figure it out.
Some help would be great.