[pmwiki-users] Is there a way to have a "default" markup for an unknown or empty page text variable?

Petko Yotov 5ko at 5ko.fr
Wed Oct 30 12:41:40 PDT 2019


On 30/10/2019 18:34, Peter Kay wrote:
> So for multiple languages, one would say
> 
>    $DefaultUnsetPageTextVars['AdminTasks'] =
>     '[[SiteAdmin.Tasks?action=login|'.XL('login to see your 
> tasks').']]';
> 
> ?

This should work in config.php :

   [[SiteAdmin.Tasks?action=login| $[login to see your tasks] ]]

because the translations $[...] will be expanded when the markup on the 
page is processed, that is after all configurations have been set.

The XL() call will only work after an XLPage() call defining the 
alternative language. If the XLPage() call is in a local/Group.php page, 
the XL() call should be after it, not in config.php.

Petko

> On Wed, Oct 30, 2019 at 5:56 AM Petko Yotov <5ko at 5ko.fr> wrote:
> 
>> I've added this for 2.2.121 (you can get the pre-release as a ZIP file
>> or from Subversion here:
>> 
>>    https://www.pmwiki.org/wiki/PmWiki/Subversion
>> 
>> Only pmwiki.php was modified for this feature since 2.2.120.
>> 
>> The documentation for this is here:
>> 
>>    https://www.pmwiki.org/wiki/PmWiki/PageTextVariables#default
>> 
>> Note that it doesn't distinguish "var not defined in page" from "user
>> has no permissions for page". But if you *know* that a specific 
>> variable
>> *is* defined in a specific protected page and it looks like unset, 
>> then
>> the user doesn't have read permissions.
>> 
>> For example, in config.php:
>> 
>>    $DefaultUnsetPageTextVars['AdminTasks'] =
>>     '[[SiteAdmin.Tasks?action=login|login to see your tasks]]';
>> 
>> then e.g. in Site.SideBar:
>> 
>>    {SiteAdmin.Tasks$:AdminTasks}
>> 
>> 
>> With earlier PmWiki versions you could use a conditional:
>> 
>>    (:if auth read SiteAdmin.Tasks:)
>>    {SiteAdmin.Tasks$:AdminTasks}
>>    (:else:)
>>    [[SiteAdmin.Tasks?action=login|login to see your tasks]]
>>    (:ifend:)
>> 
>> If the value is a single line without quotes, you could alternatively
>> use:
>> 
>>    (:if equal "" "{SiteAdmin.Tasks$:AdminTasks}":)
>>    (no permissions)
>>    (:ifend:)
>> 
>> See:
>> 
>> https://www.pmwiki.org/wiki/PmWiki/ConditionalMarkup#built-in-conditions
>> 
>> Petko
>> 
>> --
>> If you upgrade :  http://www.pmwiki.org/Upgrades
>> 
>> 
>> On 29/10/2019 22:35, Christopher Cox wrote:
>> > Is there a way to have a "default" markup for an unknown or empty page
>> > text variable?
>> >
>> > Specifically, might be nice for "something" to show up for a PTV for
>> > which somebody can't access because of permissions, but I'm ok with
>> > some sort of general case.  Possible?
>> >
>> > I'm ok with enabling such via special per group/page php.
>> >
>> > But doesn't seem possible at all today?  Like a
>> > PCache[pagename]["=p_<whatever>] default set in PageTextVar even for
>> > situations where the PCache can't be fetched due to permissions.
>> > Something like that.
>> 
>> _______________________________________________
>> pmwiki-users mailing list
>> pmwiki-users at pmichaud.com
>> http://www.pmichaud.com/mailman/listinfo/pmwiki-users
>> 



More information about the pmwiki-users mailing list