[pmwiki-devel] Page Vars - A Little Help?

Petko Yotov 5ko at 5ko.fr
Fri Mar 25 15:52:08 CDT 2011


On Friday 25 March 2011 13:07:31, Hans wrote :
> Friday, March 25, 2011, 11:27:36 AM, Eemeli wrote:
> > In your function, $FmtPV hasn't been made a global, so you end up
> > creating a local variable with $FmtPV['$price'] = "$price"; that goes
> > out of scope at the end of the function.
> 
> Even if $FmtPV is declared global
> I don't think you can set an entry to $FmtPV in a function called by
> markup, and have it evaluated in the page, because it comes much too
> late in the page rendering process.
> Or am I wrong here?

You are correct. At the time the directive is processed, everything that looks 
like a Page(Text)Variable in the form {$Var} or {$:Var} has already been 
converted to its value, which by default is empty.

If Steven needs to use the value without his function modifying it, the best 
way is to write directly PageTextVariables in the page source, like Hans and 
Eemeli suggested.

If the custom function needs to perform some processing and return a different 
value than what is written in the page source, it might be easier to use a 
custom MarkupExpression - there are some documents and examples on the wiki 
and the file scripts/markupexpr.php shipped with PmWiki could serve as a base.

Petko



More information about the pmwiki-devel mailing list