On 25 March 2011 11:05, Steven Leite <steven_le...@kitimat.net> wrote: > I'm having a bit of trouble trying to add a Page Variable via my script. > > [...] > > my_function($args) > { > $my_vars = ParseArgs($args); > if (isset($my_vars['price'])) > { > // set page variable for 'price' > $price = $my_vars['price']; > $FmtPV['$price'] = "$price"; > } > return; > }
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. However, on a more meta-level you do seem to be re-implementing the functionality of pagetext variables. What I think Hans was asking wasn't why you weren't outputting PTV markup from your function, but rather asking why you're trying to create a custom (:setpv ...:) when (:ptv:value:) would work just as well? And if you're set on creating your own function, I'd recommend looking at adding an entry to $PageTextVarPatterns like '/(\\(: *setpw +(\\w[-\\w]*) *=(?!\\))\\s?)(.*?)(:\\))/s'. eemeli _______________________________________________ pmwiki-devel mailing list pmwiki-devel@pmichaud.com http://www.pmichaud.com/mailman/listinfo/pmwiki-devel