[pmwiki-devel] how to access MatchCount from pagelist

Patrick R. Michaud pmichaud at pobox.com
Fri Feb 13 09:52:39 CST 2009

On Fri, Feb 13, 2009 at 10:07:49AM +0100, Peter Bowers wrote:
> Right now pagelist is constructed somewhat as a chain link.   
> FmtPageList calls $fmtfn (usually FPLTemplate()) which calls 
> makepagelist().  No ifs, ands, or buts -- one calls the other 
> which calls the last one.  As a result there's very
> little possibility of any interaction in the process there...

False.  One can easily change $fmtfn to call whatever sequence
you prefer -- indeed, that's why it exists.

> If it were structured like this (function names intended for
> self-documentation, not for actual use):
> function DoAPageList()
> {
>    PageListOptionSetup();
>    $matchlist = MakeListOfPages($selection_options);
>    FormatPageList($matchlist, $formatting_options);
> }

The reason why FPLTemplate() does the call to MakePageList()
is that we want it to be possible for the template to supply
default options to the pagelist (via the (:template default ... :)
markup).  Thus the MakePageList() call has to occur _after_ 
we start processing the template.

> Basically what I'm suggesting [...] is
> to separate the functionality of a pagelist.  (a) Part of it is setting up
> defaults and options.  Another part (b) is getting the appropriate list of
> pages.  The last part (c) is actually formatting said list.  

Since the formatter has/wants the ability to influence the
"get the appropriate list of pages" part, it's not quite as
straightforward as this.

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.


More information about the pmwiki-devel mailing list