[pmwiki-users] HTML cache
Patrick R. Michaud
pmichaud at pobox.com
Sun Jun 10 13:10:14 CDT 2007
On Sun, Jun 10, 2007 at 08:17:13AM +0200, Christophe David wrote:
> >For really fast processing and output of pagelists, one should
> >really create a custom formatting function for pagelist and not
> >rely solely on the markup rendering engine. Prior to pagelist
> >templates, this is how we did all of our output stuff.
>
> I am afraid I missed something here. Do you mean there already was a
> way to produce the same result as pagelists with templates in a faster
> way, but that it requires the programming of a custom function ?
Yes. PmWiki and most people have switched over to using pagelist
templates for most output -- it's easier to customize -- but PmWiki
still retains the capability to use custom output formatting functions.
For example, scripts/transition.php contains the FPLByGroup()
function that was in PmWiki before we had the [[#bygroup]]
pagelist template. That's a good model to work from.
Essentially, a custom formatting function will generally look like:
function FPLMyCustom($pagename, &$matches, $opt) {
$matches = MakePageList($pagename, $opt, 0);
$out = 'opening output';
foreach($matches as $m) {
$out .= 'formatting for each item';
}
$out .= 'closing output';
return $out;
}
To make this custom format available as a fmt= option, set
$FPLFormatOpt['mycustom']['fn'] = 'FPLMyCustom';
An author can then use "fmt=mycustom" to invoke the FPLMyCustom()
function for formating the pagelist output.
----
As a more complete example, here's a function to output a pagelist
as a simple bullet list of pagenames, callable by using "fmt=mysimple":
function FPLMySimple($pagename, &$matches, $opt) {
$matches = MakePageList($pagename, $opt, 0);
$out = '<ul>';
$itemfmt = "<li><a href='{\$PageUrl}'>{\$FullName}</a></li>\n";
foreach($matches as $m) {
$out .= FmtPageName($itemfmt, $m);
}
$out .= '</ul>';
return $out;
}
$FPLFormatOpt['mysimple']['fn'] = 'FPLMySimple';
Hope this helps -- let me know if you need any further hints.
Pm
More information about the pmwiki-users
mailing list