At 2011-02-04 05:17, Peter Bowers wrote:
On Fri, Feb 4, 2011 at 1:04 AM, Thomas Lundgren <[email protected]> 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;

my_cookbook.php
========
Markup('my_function', '_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'';

        return;
}
========


In config.php
========
include_once("$FarmD/cookbook/my_cookbook.php");
========


On the PmWiki-page
========
(:my_function:)

{$MyVariable}
========

Regards,
Thomas.

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to