Loading...
 
Features / Usability

Features / Usability


TikiWiki Plugins – Issues with Using Double Quotes to Pass Parameters in 1.9.11

posts: 11

I found TikiWiki's use of plugins to be an excellent substitute for the lack of built-in support for parameterized templates as found in MediaWiki - http://www.mediawiki.org/wiki/Help:Templates

I referred to the following instructions to create a php-based plugin:
http://dev.tikiwiki.org/tiki-index.php?page=Hello+World#To_create_a_new_plugin

They work great but with one caveat:

The use of double-quotes which are necessary for displaying strings with commas seems to create problems. For instance with a simple "HelloThere" plugin syntax
Copy to clipboard
{HELLOTHERE(firstname=> lastname=>)}{HELLOTHERE}
:

This invokes the following simple function:

Copy to clipboard
function wikiplugin_hellothere($data $params) { extract ($params EXTR_SKIP); $strHello = "Hello there $firstname $lastname" ; return $strHello; }

Copy to clipboard
{HELLOTHERE(firstname=>"Thurston" lastname=>Howell)}{HELLOTHERE}

yields
Hello There Thurston Howell.
Great!

Copy to clipboard
HELLOTHERE(firstname=>"Thurston" lastname=>"Howell III Esq. CPA")}{HELLOTHERE}
yields

Hello There Thurston Thurston.
Not so great...

Namely adding double-quotes to get around the issue of commas within strings introduces a whole other problem of its own – repetition of the first variable. When there are 10 variables for instance the first quoted value will be repeated 10 times.

I am using TikiWiki 1.9.11; has anyone encountered this issue and if so is there a remedy?

posts: 4656 Japan

Did you try single quotes? Sometimes it makes a difference.

-- Gary


posts: 11

Thanks Gary; unfortunately using single-quotes yields the following:
Hello there 'Thurston' 'Howell'

Also somehow the commas got stripped out when I posted...

This behavior appears to apply to all plugins in 1.9.11 (although I am told it is fixed in 2.0):

1. Using double quotes on multiple parameters only the first param gets passed properly
2. Removing double quotes gets around the issue but will not allow for commas in the string.

For instance the following BOX plugin argument does not give the intended result:

Copy to clipboard
{BOX(title=>"Welcome to Paradise My Friend" bg=>"green" width=>"25%" align=>"left" float=>"right")}TEST{BOX}


But when the double quotes are removed all is good.