[pmwiki-users] [pmwiki-devel] understanding pagelist default parameters
Petko Yotov
5ko at 5ko.fr
Mon Mar 23 09:24:09 PDT 2026
Thank you Simon for opening a PITS entry. Cross-posting to the mailing
list to give this more visibility.
Currently, a pagelist argument with no value like:
arg_name= or arg_name:
"arg_name=" or "arg_name:"
is considered the string "arg_name=", and returned as positional, not
named, argument. This may cause unexpected behavior for pagelists
(search string), input elements (value or something unpredictable), and
wikistyles (unintended class name) and in most core and custom
directives.
This is processed in ParseArgs(), a function used very widely in various
situations in the core and in recipes.
Simon's suggestion is, if the parsed string has something looking like
an argument name pattern with no value:
arg_name=
arg_name:
and it is NOT quoted, then this should be skipped, considered not set,
not empty, just null/missing. This would allow for the argument to be
defined by (:template default:), (:input default:) or in a function by
SDVA().
I've prototyped a fix for pagelists, but I wonder if this should become
standard.
There could be a switch as a third argument to ParseArgs(), or a global
variable toggle, or just do it the new way. I did the first one but am
considering the third one.
The pagelist/search documentation mentions that if a search term has "="
or ":" it should be quoted.
Would anyone currently use arg_name= without quotes, and need it
intentionally as a positional argument?
Do I miss some edge that a change may break?
Petko
On 22/03/2026 21:57, Simon wrote:
> Thankyou, I now see the problem (I think?)
>
> I would have expected, say, in this statement (from a SideBar)
> (:pagelist name=A* fmt=Songbook.SideBar#listbyletter
> category={*$:genre} :)
> the parameter category= NOT to morph into a search string if the page
> text variable {*$:genre} is not defined on a page body.
>
> It seems to me that if a user desires a search string of "category="
> they should quote it.
>
> thanks
>
> Simon
>
> On Fri, 20 Mar 2026 at 20:14, Petko Yotov <5ko at 5ko.fr> wrote:
>
>> The argument category= without anything after the "=" is considered
>> a
>> search string and the pagelist shows pages containing the literal
>> string
>> "category=" in the page text.
>>
>> You can use category="" but this overrides your template default.
>>
>> If you populate this argument from a page text variable, there are
>> $DefaultEmptyPageTextVars and $DefaultUnsetPageTextVars:
>>
>> $DefaultUnsetPageTextVars['genre'] = '*';
>> $DefaultEmptyPageTextVars['genre'] = '*';
>>
>> This should work for the pagelist argument, but may not work well if
>> you
>> display the {*$:genre} variable elsewhere.
>>
>> Otherwise you could have a conditional with 2 pagelists, something
>> like
>> this:
>>
>> (:if332 empty "{*$:genre}":)
>> (:pagelist ... category=*:)
>> (:else332:)
>> (:pagelist ... category="{*$:genre}":)
>> (:if332end:)
>>
>> Petko
>>
>> --
>> If you upgrade : https://www.pmwiki.org/Upgrades
>>
>> On 20/03/2026 06:27, Simon wrote:
>>> I have a test here:
>>> https://www.pmwiki.org/wiki/Test/PagelistWithCategoryParameter
>>>
>>> It has defaults, viz
>>>
>>> (:template defaults group=Cookbook order=name category="*" count=5
>> :)
>>>
>>> I'm trying to understand why
>>> (:pagelist name=W* fmt={$FullName}#listbyletter :)
>>> appears to give a different result from
>>>
>>> (:pagelist name=W* fmt={$FullName}#listbyletter category= :)
>>> thanks
>>>
More information about the pmwiki-users
mailing list