Topic on Extension talk:PhpTags

Pass mediawiki template parameter to/from php?

3
Nuada99 (talkcontribs)

Is there some way to pass a mediawiki template variable to the <phptag> section of code? For that matter, is there a way to have one or more outputs of the php become the result of a template parameter?

For example:

{{Template:TestingPHP

| parameter1 = 99+21

| parameter2 = {{#phptag: $foo = {{{argument1}}}; $bar = explode("+", $foo); echo $bar[1]; }}

}}

Ideally, the value of "parameter2" would become the second element of the $bar array (21), but instead I get a php error. It doesn't seem to like the curly-braces of template parameters.

Apologies if this is a stupid question. I'm still wrapping my head around php.

Pastakhov (talkcontribs)

Hi, You going to use {{{argument1}}} as a PhpTags code, it isn't very nice idea and solution.

As a variant you may get access to argument1 by using special variable $argv for example

{{Template:TestingPHP

| parameter1 = 99+21 | parameter2 = {{#phptag: $foo = $argv['argument1']; $bar = explode("+", $foo); echo $bar[1]; }}

}}

Pastakhov (talkcontribs)
Reply to "Pass mediawiki template parameter to/from php?"