[pmwiki-users] Fwd: Pagelist sorting by by page text variables

Peter Bowers pbowers at pobox.com
Fri Jun 28 07:38:53 CDT 2013


I neglected to reply-to-all when I replied to Simon's email...

See below.

-Peter

---------- Forwarded message ----------
From: Peter Bowers <pbowers at pobox.com>
Date: Thu, Jun 27, 2013 at 10:48 PM
Subject: Re: [pmwiki-users] Pagelist sorting by by page text variables
To: Simon <nzskiwi at gmail.com>


On Thu, Jun 27, 2013 at 2:52 PM, Simon <nzskiwi at gmail.com> wrote:
>...

> That is very confusing.
> The variables are displayed correctly when used in the pagelist.
> But you are saying not when used by the pagelist.

In the pagelist template you list your PTVs using the special syntax
{=$:var} where the = sign tells pagelist that this needs to be processed
directly by the pagelist script itself and not to wait for other rules to
process it.  But if you set a variable like this:

(:foo:This is from page {$FullName}:)

and then include {=$:foo} in your template then the pagelist script will
change that to "This is from page {MyGroup.MyPage$FullName}" but it is
subsequent rules in your ruleset that actually translate the PV (or PTV)
into its actual value.  So the end user sees the value, but the pagelist
script itself never saw those actual values.

> This sound like a bug to me.
> '
> It certainly doesn't give the expected result (PmWiki Philosophy #1
Favour writers over readers)

I'll leave the philosophy question to PM or Petko, but I think I can give
the practical answer to that question.  Pagelists must have been one of the
most difficult parts of the pmwiki engine to make them complete in a
reasonable period of time -- think of the vast amount of data that must be
potentially processed.  There have been huge efforts (amazingly successful)
to optimize pagelist to the point where it works great in most real-world
applications.  However, there have to be some trade-offs in order to allow
it to do all it does in such a short time.

In order to make it work with full PTV and Markup Expression capabilities
within the pagelist script itself you would have to either (a) cache values
of all PTVs or (b) process each and every rule in the entire ruleset for
each page processed by pagelist (for fullest capability with no limitations
you would have to process every single page on the whole site for every
call of the pagelist markup).  (a) would cause problems with a loss of
dynamic functionality (imagine this PTV: (:dayofweek:{(ftime "%A")}:) --
obviously caching this value would lose this capability.  (b) would cause a
huge performance hit making pagelists unwieldy and useless in many
real-world applications.

So I can see where it is frustrating to you, having set up your pages in a
way that makes sense but that pagelist cannot handle.  But I'm afraid the
alternative is not really acceptable to anyone...

For your specific issue, if your pages on your site are consistently named
as YYYYMonth then setting up $FmtPV['monthnum'] [1] will both solve your
problem as well as get you potentially significant performance gains as
compared to what the markup expression would have done had it worked...
(There's quite a bit of overhead that a markup expression has to undertake
that a quick call to a function in $FmtPV would not require.)

-Peter

[1] Something like this should suffice:

$FmtPV['$MonthNum'] = 'MonthNum($pagename, $name)';
function MonthNum($pagename, $name)
{
    $months = array('January'=>'01', 'February'=>'02', 'March'=>'03',
'April'=>'04', ...);
    #echo "DEBUG: ".substr($name, 4)."<br />\n";
    if ($mn = @$months[substr($name, 4)])
        return $mn;
    else
        return '00'; // or some suitable error value
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.pmichaud.com/pipermail/pmwiki-users/attachments/20130628/002519bd/attachment.html>


More information about the pmwiki-users mailing list