[pmwiki-users] Using variable in skin template

DaveG pmwiki at solidgone.com
Sat Oct 24 10:04:34 CDT 2009

Hans wrote:
> Friday, October 23, 2009, 11:56:25 PM, DaveG wrote:
>>> Parse error: syntax error, unexpected T_STRING in
>>> /<path>/pmwiki.php(762) : eval()'d code on line 1
>> That's because the PageVar needed to be quoted, as Hans showed. Thus,
>>     $FmtPV['$myvar'] = 'PageVar($pagename,\'$:myvar\')'
> There were in fact several things wrong with your code:
> 1. missing quotes

> 2. wrong function: PageTextVar() is used to exctract a PTV
Actually, either function works, as PageVar calls PageTextVar. It is 
probably mildly faster to call PageTextVar directly though.

> 3. use of $pagename: use $pn rather than $pagename as $ pagename may
>    have a different value.
Not sure about this. Is $pn globally available? Not sure, but it doesn't 
look like it. I'd always thought $pagename referred to the current page 
from within skin/config files.

> 4. PTV name: if the PTV is named in the page 'myvar', then
>    that should be used a parameter in the PageTextVar() call.
>    PageVar($pn, "myvar")
>    {$:myvar} is the syntax to refer to th ePTV in a wiki page.
That's correct when calling PageTextVar. But called from PageVar, then 
the $:myvar format is used.

  ~ ~ David

More information about the pmwiki-users mailing list