01315: Complex page text variables in pagelist sort

Summary: Complex page text variables in pagelist sort
Created: 2013-06-29 22:59
Status: Open
Category: Feature
From: simon
Priority: 4
Version: 2.2.52
OS: n/a

Description: See PageListSortPTV.

Where a page text variable is of the form

(:MonthNum:{(ftime fmt="%m" when="February")}:)

containing a markup expression

the pagelist does not sort correctly when sorted by page text variable.

Peter Bowers explains this as follows: (from email list)

Pagelist does not evaluate markup expressions when working with PTVs and neither are the PTV values cached anywhere. Therefore pagelist is sorting the literal values of open-curly-brace followed by open-paren followed by the 5 characters "f-t-i-m-e" etc. Since these literal values are identical across all your pages you end up with what appears to be random ordering.

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", 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.

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.

The pages are set up in a way that makes sense, but that pagelist cannot handle. The alternative is not really acceptable to anyone...