[pmwiki-users] HTML cache
Patrick R. Michaud
pmichaud at pobox.com
Mon Jun 11 14:28:14 CDT 2007
On Mon, Jun 11, 2007 at 02:46:37PM +0200, Christophe David wrote:
> >This will create a list of the values of $:MyPageTextVariable
>
> It looks that using a custom function instead of a pagelist template
> has a side effect on the count= parameter, which does not appear to be
> processed correctly.
>
> fmt=#MyFormat (defined in LocalTemplates) : count= works OK
>
> fmt=MyFunction (defined in PHP) : count= does not work
>
> Is that the intended behaviour ?
A custom formatting function needs to do its own handling of
count= ... MakePageList() doesn't do it automatically. We leave
it up to the formatting function to perform, because it may want to
do some further processing on the pagelist before taking a count.
The code that FPLTemplate() uses for processing any count=
option is:
if (@$opt['count']) {
list($r0, $r1) = CalcRange($opt['count'], count($matches));
if ($r1 < $r0)
$matches = array_reverse(array_slice($matches, $r1-1, $r0-$r1+1));
else
$matches = array_slice($matches, $r0-1, $r1-$r0+1);
}
Or, I could change the core so that MakePageList() does the
processing of count, and any formatting function that wants
to avoid MakePageList() prematurely chopping the list would
need to set 'count=' prior to calling MakePageList(). That
might be more natural for most people writing custom pagelist
formatters.
Pm
More information about the pmwiki-users
mailing list