[pmwiki-users] FmtPageList undefined

Peter Bowers pbowers at pobox.com
Tue Jul 21 17:06:09 CDT 2009


On Tue, Jul 21, 2009 at 1:15 PM, Hans<design5 at softflow.co.uk> wrote:
> Tuesday, July 21, 2009, 5:37:43 PM, Peter Bowers wrote:
>
>> I believe you are seeing "kept" values that are never replaced back.
>
> It was a very short string, which should have been a long list of
> page names.

Yes, the Keep() function replaces the whole long list of pagenames
with a Keep Token which consists (by default) of 2 generally unused
ascii characters (See $KeepToken setting in pmwiki.php) followed by a
unique number within a pool followed by the pool designation followed
by those 2 ascii characters again.  So if we are in a markup
expression the pool is "P" and the 4th kept string would look like
this:

XX4PXX

But the X is some generally invisible/nonprinting character which
probably only appears if you "view source."  So all you see is 4P.

This is generally replaced at the end of markup expression processing
(in scripts/markupexpr.php) like this:

  $rpat = "/$KeepToken(\\d+P)$KeepToken/e";
  $rrep = '$KPV[\'$1\']';
  ...
  return preg_replace($rpat, $rrep, $expr);

So that would have replaced XX4PXX with the list of pagenames again.
But since in Adam's config.php the underlying functions are being
called directly rather than through the markup expression engine this
final substitution never occurs.

If you are looking for the list of pages in an array then Hans's
MakePageList() is exactly what you need.  (It's probably a lot faster
too.)

If you are wanting to use the built-in formatting capabilities of
pagelists (with templates and etc) then you can either call
FmtPageList() and mess with the keep tokens afterwards (which, I agree
with Hans, is complicated) or you could go a bit higher level and call
MarkupExpression(), simply passing it the expression you would have
given it on a page within {(...)}.  (IIRC you pass just the
parenthesized expression without the curly braces --
MarkupExpression($pagename, "(pagelist group=xyz fmt=csv)") or
something like that.)

You will almost certainly need to do all of this in a custom action or
something, as has already been noted.  Code in config.php just occurs
too early to be able to effectively make use of a lot of scripts.

-Peter



More information about the pmwiki-users mailing list