Loading...
 
Skip to main content

Features / Usability


Extracting Plugin Parameters

How do I access the parameters passed into a Plugin? When I try to output $params in the php script, all I see is "Array". If I try to output $params0, I get an undefined "offset" error. Ideas? I've checked the doc's but they don't shed a lot of light on how to do this... unless I missed the link or something.

You could have lokked into the existing plugins 😬, like e.g. lib/wiki-plugins/wikiplugin_quote.php

Copy to clipboard
extract ($params,EXTR_SKIP);

This extracts the parameters so you can use them like this:

{CODE()}if (!empty($replyto)) ...
Copy to clipboard


Simply test for it. For example, if your plugin is:

Copy to clipboard
{MYPLUGIN(foo=xxx)}some text{MYPLUGIN}


Your code may look like:

Copy to clipboard
... if (isset($foo)) { ..do something... } else { ..do somehting else... } ...



HTH,

RickQuestion

Thanks, Ricks - that did the trick again. I see, though, that the docs actually *do* cover how to do this, so sorry for bothering everyone over it.

Ok, nvm folks. Figured out what the problem was. I was trying to output a div tag on the same line as the Tiki tag, all I needed to do was output a line feed in the string between the div and quicktag and that got it working ok.