[pmwiki-devel] FPLTemplate() Revision

Hans design5 at softflow.co.uk
Mon Feb 16 09:08:04 CST 2009


Following from the discussion about pagelist and MatchCount I created
a revised FPLTemplate() function, for testing and as proof-of-concept
idea.

See code http://www.pmwiki.org/wiki/Cookbook/FPLTemplate

For testing install fpltemplate.php as standard cookbook recipe.
Doing so will make pagelist to use the included functions instead of
the original FPLTemplate function.

Comments about changes made are in the script.

Features:

    * Original function broken into 5 (sub-)functions, called in a
      chain, offering possibilities of adding custom functions into the
      chain.
    * Additional pagelist supplied by custom function can be merged
      with list returned by MakePageList() function
    * Additional {$$PageListCount} template variable, giving total
      count of pagelist before any slicing into chunks.
    * Additional optional start= parameter for (:pagelist:)
    * Additional optional (:template none:) as template section for
      the case of "no matches"

The five sub-functions:

SDV($FPLTemplateFunctions, array(
   'FPLTemplateLoad',      //load pagelist template
   'FPLTemplateDefaults',  //add any defaults from template to options
   'FPLTemplatePageList',  //make pagelist, calls MakePageList(), merges with previous list
   'FPLTemplateSliceList', //slice pagelist according to start= and count= parameters
   'FPLTemplateFormat'));  //construct and return HTML formatted output

I like to offer this as a contribution to the discussion about revising
FPLTemplate(), and as suggestion for a possible development of FPLTemplate().

Even though this works as a recipe, I hope we can have something like
this as the core function. I tried to split the original with minimal
changes, adding a few features which were long requested.

The split into five sub functions may seem excessive, but each
presented itself as a logical unit.

I invite your comments!

Hans




More information about the pmwiki-devel mailing list