<section id="[[!+pagetitle]]" class="text-center section-padding wayp wp2 [[!+idx]]" role="complementary">
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<article class="contents bloc-txt">
[[!+content]]
[[!+idx:incr]]
<a class="down-arrow-btn" href="#more-about2"><i class="glyphicon glyphicon-chevron-down"></i></a>
</article>
</div>
</div>
</div>
</section>
<?php
$parent = $modx->getOption('parents',$scriptProperties,$modx->resource->get('id'));
$outputSeparator = $modx->getOption('outputSeparator',$scriptProperties,'');
$tpl = $modx->getOption('tpl',$scriptProperties,'');
$classname = 'modResource';
$c = $modx->newQuery($classname);
$c->where(array('published'=>1,'deleted'=>0,'parent'=>$parent));
$c->sortby('menuindex');
$rows = array();
if ($collection = $modx->getCollection($classname,$c)){
foreach ($collection as $object){
$rows[] = $object->toArray();
}
}
$output = array();
foreach ($rows as $key => $row){
//get pagetitle of next row
$nextkey = $key+1;
$nextrow = isset($rows[$nextkey]) ? $rows[$nextkey] : array();
$row['idx'] = $nextkey;
$row['nextpagetitle'] = $modx->getOption('pagetitle',$nextrow,'');
$output[] = !empty($tpl) ? $modx->getChunk($tpl,$row) : '<pre>' . print_r($row,1) . '</pre>';
}
return implode($outputSeparator,$output);
?>
[[+nextpagetitle]]
you could replace getResources with something like that (untested)
<!--?php $parent = $modx--->getOption('parents',$scriptProperties,$modx->resource->get('id')); $outputSeparator = $modx->getOption('outputSeparator',$scriptProperties,''); $tpl = $modx->getOption('tpl',$scriptProperties,''); $classname = 'modResource'; $c = $modx->newQuery($classname); $c->where(array('published'=>1,'deleted'=>0,'parent'=>$parent)); $c->sortby('menuindex'); $rows = array(); if ($collection = $modx->getCollection($classname,$c)){ foreach ($collection as $object){ $rows[] = $object->toArray(); } } $output = array(); foreach ($rows as $key => $row){ //get pagetitle of next row $nextkey = $key+1; $nextrow = isset($rows[$nextkey]) ? $rows[$nextkey] : array(); $row['idx'] = $nextkey; $row['nextpagetitle'] = $modx->getOption('pagetitle',$nextrow,''); $output[] = !empty($tpl) ? $modx->getChunk($tpl,$row) : '<pre>' . print_r($row,1) . '</pre>'; } return implode($outputSeparator,$output); ?>
Then you would have the next pagetitle in each tpl-chunk with[[+nextpagetitle]]
[[!getResources? &tpl=`GR-tpl` &tpl_0=`GR-tplFirst` &first=`8` &includeContent=`1` &sortby=`menuindex` &sortdir=`ASC` &idx=`[[+idx]]` ]]
Maybe a combination of pdoResources and pdoNeighbours could solve your problem too, both snippets are part of the pdoTools extra, pdoResources serves very well as a faster replacement for getResources and pdoNeighbours can show prev and next resources (e.g. siblings), if it cannot output the ids of these documents, you could maybe adjust the snippet a bit or you just set the template to a chunk with no markup and probably [[+id]] as only content?!
[[!pdoRessources? &parents=`1` &sortby=`FIELD(modResource.id, '[[*menuindex]]')` &sortdir=`ASC` &tpl=`@INLINE <li>[[+pagetitle]]</li>` &showLog=`1`]]