[pmwiki-devel] how to access MatchCount from pagelist

Hans design5 at softflow.co.uk
Sat Feb 14 04:07:36 CST 2009


Thanks for your suggestions Peter!

Unfortunately, the issue still remains unsolved:
Namely for the kind of dynamic navigation links I need to get first
the total count of pagelist matches, then calculate the last match
and the range of matches to be shown.

At present it still needs two runs of pagelist, or of MakePageList at
least.

Patrick wrote:

> I suppose it would be possible for us to parse the template
> page twice, or to try to otherwise breakup FPLTemplate into
> separate stages for "getting options" and "generating the list",
> but when I mentally try to code it that way I get a bad feeling
> about the result.

I would not like it to run twice, because it seems a lot of extra
work: MakePageList is called twice, and the formatting occurs twice.

I wonder if breaking FPLTemplate into three functions could be
a feasible solution:
FPLTemplateDefaults -> MakePageList -> FPLTemplateFormat

If this is set up as an array of functions to be processed in series,
a developer could add custom function for instance before
MakePageList, or after it, or wherever.

For the example of dynamic navigation links I would add a custom
BreakPageList function after MakePageList:
then the function has the total of PageListCount, calculates the last
nav link and the range for setting pagelist count=Range, i.e.
$opt['count'] can be reset before the splicing of the pagelist
matches.

The advantage is that MakePageList is called just once, and
formatting results is also done just once.
The BreakPageList function possibly could even construct replacement
variables (pseudovars) for use in nav links coded in the pagelist
template (but this may be too fussy and complicated).
Still, it opens huge opportunities.

Hans




More information about the pmwiki-devel mailing list