[pmwiki-users] Keeping result of markup expression only

Petko Yotov 5ko at 5ko.fr
Thu Jan 25 08:44:58 CST 2018


On 23/01/2018 23:03, Robert Riebisch wrote:
> I have pages with names like, e.g., "FlagsOfOurFathers-2006".
> Content of this page starts with:
> (:title Flags of Our Fathers ({$:ReleaseYear}):) (:ReleaseYear:{(substr
> {$BaseName} -4)}:)
> 
> It displays fine: Flags of Our Fathers (2006)
> But I use pagelist on another page to filter for pages with ReleaseYear
> = 2006. This doesn't work anymore, because ReleaseYear has the value of
> the markup expression (...substr...), but not just "2006".
> 
> Is there a way with the default OOTB PmWiki installation to just keep
> the result of the markup expression only?

It depends on what you consider "default out of the box".

No, there is no way without editing config.php or including an addon.

Yes, there is a way to only edit config.php to have the result you need, 
but not via the markup expressions feature, see below.

> I found an additional recipe
> <http://www.pmwiki.org/wiki/Cookbook/MarkupExprPlus>,

This recipe will not help, it functions the same way as the core 
expressions which are not yet evaluated when the pagelist is 
ordered/filtered.

To make a custom sort for a pagelist, best is to use a custom 
PageVariable, not a PageTextVariable, something like this in config.php:

   $FmtPV['$ReleaseYear'] = 'ReleaseYear($pn)';
   function ReleaseYear($pn){
     $basename = MakeBaseName($pn);
     return substr($basename, -4);
   }

Then in the (:pagelist:) directive, use "order=$ReleaseYear" or 
"$ReleaseYear=2016", and in the template use {=$ReleaseYear} instead of 
{=$:ReleaseYear}.

It may be interesting for this to be doable OOTB though, I'll think 
about adding a switch to evaluate variables and expressions when a 
pagelist is processed.

> but I wish to keep
> my PmWiki installation lean for easier maintenance.

PmWiki is the probably the easiest piece of complex web software I know 
when it comes to maintenance, it is designed for easy maintenance, see 
PmWiki Philosophy. If you don't modify the core files, and you never 
should need to, you upgrade by simply replacing the old core files with 
those from a more recent version, and it should work fine (read the 
release notes in case your installation needs something additional). We 
never break existing addons, or if this happens very rarely, we either 
revert the changes in the core or provide assistance for the recipe 
authors and webmasters on how to update their addons. PHP regularly 
breaks PmWiki and addons, but that's out of our control so we fix it and 
document it when it happens.

Petko



More information about the pmwiki-users mailing list