<div dir="ltr">I neglected to reply-to-all when I replied to Simon's email...<div><br></div><div style>See below.</div><div><br></div><div>-Peter<br><br><div class="gmail_quote">---------- Forwarded message ----------<br>

From: <b class="gmail_sendername">Peter Bowers</b> <span dir="ltr"><<a href="mailto:pbowers@pobox.com">pbowers@pobox.com</a>></span><br>Date: Thu, Jun 27, 2013 at 10:48 PM<br>Subject: Re: [pmwiki-users] Pagelist sorting by by page text variables<br>

To: Simon <<a href="mailto:nzskiwi@gmail.com">nzskiwi@gmail.com</a>><br><br><br><div dir="ltr"><div><div>On Thu, Jun 27, 2013 at 2:52 PM, Simon <<a href="mailto:nzskiwi@gmail.com" target="_blank">nzskiwi@gmail.com</a>> wrote:<br>

>...<div class="im"><br>> That is very confusing.<br>> The variables are displayed correctly when used in the pagelist.<br>
> But you are saying not when used by the pagelist.<br><br></div></div>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:<br>


<br></div>(:foo:This is from page {$FullName}:)<br><br>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.<br>


<div><div class="im"><div><br>> This sound like a bug to me.<br>> '<br>> It certainly doesn't give the expected result (PmWiki Philosophy #1 Favour writers over readers)<br><br></div></div><div>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.<br>


<br>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.<br>


<br></div><div>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...<br>


<br></div><div>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.)<br>


</div><div><br></div><div>-Peter<br><br></div><div>[1] Something like this should suffice:<br><br>$FmtPV['$MonthNum'] = 'MonthNum($pagename, $name)';<br>function MonthNum($pagename, $name)<br>{<br>    $months = array('January'=>'01', 'February'=>'02', 'March'=>'03', 'April'=>'04', ...);<br>


    #echo "DEBUG: ".substr($name, 4)."<br />\n";<br>    if ($mn = @$months[substr($name, 4)])<br>        return $mn;<br>    else<br>        return '00'; // or some suitable error value<br>


}<br><br></div></div></div>
</div><br></div></div>