[pmwiki-devel] how to access MatchCount from pagelist
Hans
design5 at softflow.co.uk
Fri Feb 13 09:54:07 CST 2009
Friday, February 13, 2009, 3:33:57 PM, Patrick wrote:
> Surely we don't want $PageListCount to be a page variable,
> as the value only has meaning within the pagelist. I'm
> guessing it should be {$$PageListCount} as a template
> substitution, yes? In other words, I think it's more like
> {$$PageCount}, {$$GroupCount}, etc.
You are right. I just did not know how to get the var defined.
so now I got this code for a {$$PageListCount} templ. var:
## get the list of pages
$matches = array_values(MakePageList($pagename, $opt, 0));
$pagelistcount = count($matches);
if (@$opt['start']) {
if ($opt['start'] >= 0)
$matches = array_slice($matches, $opt['start']-1);
else
$matches = array_slice($matches, $pagelistcount+$opt['start']);
}
## extract page subset according to 'count=' parameter
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], $pagelistcount);
if ($r1 < $r0)
$matches = array_reverse(array_slice($matches, $r1-1, $r0-$r1+1));
else
$matches = array_slice($matches, $r0-1, $r1-$r0+1);
}
$savecursor = $Cursor;
$pagecount = 0; $groupcount = 0; $grouppagecount = 0;
$pseudovars = array('{$$PageListCount}' => &$pagelistcount,
'{$$PageCount}' => &$pagecount,
'{$$GroupCount}' => &$groupcount,
'{$$GroupPageCount}' => &$grouppagecount);
works fine.
Hans
More information about the pmwiki-devel
mailing list