Thanks for taking the trouble to reply, Mark. I have assumed that there is a clash between the URL rewriting script and the way getPage relies on inserting a query string into the URL, so I have set up a pagination system that doesn't rely on sending anything via the URL. It's not a system I would recommend to anyone else, but it works for this site.
In case anyone else is in the same situation, I created a sufficiently large number of resources each with consecutive ID numbers and used those to display the paginated results. Each page calls a snippet to create the page links and passes to the snippet the number of the page so the snippet knows which page is the current one. That snippet also calculates how many links to display. Each page has a second snippet to display the set of results required for that particular page (calculated using the current page number).
It is a bit of a dogs breakfast, but it works.
For the record, the snippet calls (on the first resource) are:
[[!pagination? ¤tpage=`1`]]
[[!arrangechildrenbytv? ¤tpage=`1`]]
[[!pagination? ¤tpage=`1`]]
The arrangechildrenbytv snippet collates a list of child resources ordered according to some TVs and then selects a group of them to be shown on the page:
<?php
$parentID = '22';
$tvname1 = 'region';
$tvname2 = 'sleeps';
$tplname = 'villalist';
$pagetitle = 'pagetitle';
$introtext = 'introtext';
$resultstodisplay = '12';
$villaIDs = array();
$parentresource = $modx->getObject('modResource',array(
'published' => 1,
'id' => $parentID
));
$children = $parentresource->getMany('Children');
foreach ($children as $child) {
$region = $child->getTVValue($tvname1);
$sleeps = $child->getTVValue($tvname2);
if ( ($region == 'Minho') && ($sleeps == '14-plus') ) { $vid = $child->get('id'); $cat1 .= $vid . '|'; }
elseif ( ($region == 'Minho') && ($sleeps == '9-13') ) { $vid = $child->get('id'); $cat2 .= $vid . '|'; }
elseif ( ($region == 'Minho') && ($sleeps == '5-8') ) { $vid = $child->get('id'); $cat3 .= $vid . '|'; }
elseif ( ($region == 'Minho') && ($sleeps == '1-4') ) { $vid = $child->get('id'); $cat4 .= $vid . '|'; }
} //end foreach
$allvillas = $cat1 . $cat2. $cat3 . $cat4 ;
$allvillas = trim($allvillas);
//remove last | from string
$allvillas = substr($allvillas, 0, -1);
$villaarray = explode("|", $allvillas);
$villacount = count($villaarray);
$i = 1;
$startpage = ( $currentpage * 12) - 11;
$tobreak = ( $currentpage * 12 ) + 1;
foreach ($villaarray as $key => $villa) {
if(($i >= $startpage) && ($i < $tobreak)) {
$villaid = $villa;
$villa = $modx->getObject('modResource',$villaid);
$titletoprint = $villa->get('pagetitle');
$introtoprint = $villa->get('introtext');
$regiontoprint = $villa->getTVValue('region');
$maintoprint = $villa->getTVValue('mainsummarylist');
$secondtoprint = $villa->getTVValue('secondsummarylist');
$locationtoprint = $villa->getTVValue('location');
$gallerypathtoprint = $villa->getTVValue('gallerypath');
$output .= $modx->getChunk($tplname, array(
'pagetitle' => $titletoprint,
'introtext' => $introtoprint,
'region' => $regiontoprint,
'location' => $locationtoprint,
'mainsummarylist' => $maintoprint,
'secondsummarylist' => $secondtoprint,
'id' => $villaid,
'gallerypath' => $gallerypathtoprint
));
}
$i++;
} //end foreach
return $output;
?>
The pagination snippet uses a tiny chunk to create the page numbers as list items with links:
<?php
$parentID = '22';
$resultstodisplay = '12';
$firstpageid = '254';
$tpl = 'paginationlistitem';
$children = $modx->getChildIds( $parentID );
$sumofchildren = count($children);
if($sumofchildren > $resultstodisplay) {
$pagestotal = ceil($sumofchildren/$resultstodisplay);
}
if($pagestotal > 1) {
$lastpageid = ($firstpageid + $pagestotal) - 1 ;
$output = '<div class="pagenav"><ul>';}
$i = 1;
while($i <= $pagestotal){
$rid = ($firstpageid + $i) - 1;
$pagenumbertoprint = $i ;
if($pagenumbertoprint != $currentpage){
$output .= $modx->getChunk($tpl, array(
'rid' => $rid,
'pagenumbertoprint' => $pagenumbertoprint
));
} elseif($pagenumbertoprint == $currentpage) {
$output .= '<li>'.$pagenumbertoprint.'</li>';
}
$i++;
}//end while
$output .= '</ul></div>';
}//end if pagestotal
return $output;