[pmwiki-users] Conditional Pagelist
Petko Yotov
5ko at 5ko.fr
Thu May 14 12:27:11 PDT 2020
Every argument needs to match for the page to be included in the
pagelist:
(:pagelist group=Cookbook $:Summary=*photo*,*video*
$:Maintainer=*Petko*:)
Here for a page to be included, all these need to be true:
1. page is in the group Cookbook
2. the variable {$:Summary} contains either photo or video
3. the variable {$:Maintainer} contains Petko
You cannot ask for "either" argument, "all" arguments need to match.
You can, however, use a pagelist "if" argument to check for exact values
of PTVs:
(:pagelist group=Cookbook \
if='[ equal "{=$:Maintainer}" "[[~HansB]]" || equal "{=$:Status}"
"Stable" ] ':)
This may be quite slow on a large wiki with many pages. See
documentation at:
pagelist if:
https://www.pmwiki.org/wiki/PmWiki/PageLists#pagelistif
conditionals, if equal A A
https://www.pmwiki.org/wiki/PmWiki/ConditionalMarkup#built-in-conditions
conditionals, either A or B is TRUE
https://www.pmwiki.org/wiki/PmWiki/ConditionalMarkup#combiningconditions
And, you cannot test for partial matches, and for case insensitive
matches, * means * not any character.
Note, in a PageTextVariable, exactly one space after the ":" is removed
from the value if it is there; trailing spaces are all kept. So:
"Var1: Value 1" => "{$:Var1}" gives "Value 1"
"Var2:Value 2" => "{$:Var2}" gives "Value 2"
"Var3: Value 3" => "{$:Var3}" gives " Value 3"
"Var4: Value 4 " => "{$:Var4}" gives "Value 4 "
Petko
On 14/05/2020 20:55, david at ellendee.co.uk wrote:
> Thanks Petko, I've got that. What I require is either of 2 different
> PTVs to
> be equal to a value.
>
> On reviewing my original email, I have mis-typed. Sorry.
>
> Both values should have been the same "xxx".
>
> Regards
>
> Dave
>
> -----Original Message-----
> From: Petko Yotov <5ko at 5ko.fr>
> Sent: 14 May 2020 19:15
> To: david at ellendee.co.uk
> Cc: 'PmWiki Users List' <pmwiki-users at pmichaud.com>
> Subject: Re: Conditional Pagelist
>
> On 14/05/2020 15:39, david at ellendee.co.uk wrote:
>> But is it possible to have conditions in pagelist such as (:pagelist
>> $:PTV1="XXX" or $PTV2="xxx":)
>
> I just tried in the sandbox:
>
> (:pagelist group=Cookbook $:Summary=*photo*,*video*:)
>
> It works, and lists all pages from the cookbook where the Summary: line
> contains either "photo" or "video" (or both) case insensitive.
>
>
> This lists all recipes that are maintained by me:
>
> (:pagelist group=Cookbook $:Maintainer=*Petko*:)
>
>
> Note, at first I made a typo and wrote $:Mainrainer which returned
> nothing.
>
> Asterisk * means any character(s) or no character; question mark ?
> means
> at least one character; comma apparently separates different patterns
> among which at least one needs to match, like for the name= and group=
> arguments.
>
> If you need something specific that doesn't work, feel free to create a
> few pages at pmwiki.org/wiki/Test for review.
>
> Petko
>
More information about the pmwiki-users
mailing list