[pmwiki-devel] How to properly read a PTV in a function

Petko Yotov 5ko at 5ko.fr
Mon Jan 18 16:42:08 CST 2010


On Monday 18 January 2010 18:45:02, Randy Brown wrote :
> I am working on a recipe that provides the user with a directive that
>  selects a page text variable found on a specified page. Unfortunately, I'm
>  finding that if the PTV contains a link whose target is {$FullName}, the
>  link appends "FullName" to the target. For example
> 
> on Main.MyPage:
> 
> MyPTV: [[{$FullName}?action=...etc.
> 
> The directive mistakenly gives me a link to a page named
>  "Main.MyPageFullName" as if I had written
> 
> [[{$FullName}FullName?action=...etc.

Isn't it more something like {Main.MyPage$FullName}?action= ...?

> Why does this transformation happen?

Because normally {$FullName} and [[Page]] refer to the physical page where 
they are written. When you get some text/section/trail/PTV from a page 
different from the current one, all links and page(text)variables are 
rewritten so they wouldn't break:
* {$Variable} becomes {Group.Page$Variable}
* [[Page]] becomes [[OriginalGroup/Page]]

This way, all cross-group links should continue to link to the pages they were 
intended to.

> How can I prevent it?

$QualifyPatterns is an array containing the re-writing rules. If you globally 
unset() it before calling PageVar(), and restore it after, it should work 
(untested, I'm not sure if it is the best way to do this).

Petko



More information about the pmwiki-devel mailing list