[pmwiki-users] $FmtPV

Thomas Lundgren publik at lundgren.nu
Fri Feb 4 02:12:31 CST 2011

At 2011-02-04 05:17, Peter Bowers wrote:
>On Fri, Feb 4, 2011 at 1:04 AM, Thomas Lundgren <publik at lundgren.nu> wrote:
> > On a page I call a cookbook-script-function with a markup like;
> >
> > (:my_function:)
> >
> > In the cookbook i have a function that checks the value in a form-field
> > every time it is called and sets the result in a PageVariable.
> >
> > I want to use that variable on any page as any other PageVariable like;
> >
> > {$MyVariable}
> >
> > BUT. I can´t get this to work...
> >
> > I can use $FmtPV in config.php and in the cookbook-script and set the
> > variabel $MyVariable. But I can´t change the variable content in the
> > function that is called in the cookbook-script.
>A couple easy things to check right off...
>(1) Make sure you have $FmtPV declared as a global in your function
>(2) Make sure your markup rule is ordered such that the changes you
>are making occur before they are used (i.e., '<{$var}' or before, use
>?action=ruleset with diag turned on to confirm the order)

Many thanks for you quick answer - but...

(1) I´m declaring $FmtPV as a global in my cookbook-script (se below).

(2) I think I don´t understand what you are 
saying. :)  I don´t user Markup() to set the 
variable in any way - only to create the function 
that sets the variable.... So where and how should I use the '<{$var}' ?

In short my setup looks like this;

'_begin',  '/\\(:my_function(.*?):\\)/e', 'main_function("$1")');

global $FmtPV;

function main_function( $opts )
         { code that set $ToMyVariable to what it should be... }

         $FmtPV['$MyVariable'] = '$ToMyVariable'';


In config.php

On the PmWiki-page



More information about the pmwiki-users mailing list