Loading...
 
Development

Development


How do I pass parameter to module?

posts: 34

I am createing a module, and would like to pass it a parameter. I saw a line on the admin-modules page called Parameters. How do these values show up in your scripts?

I just posted to SourceForge, then saw that this forum looked like a better place. Sorry for the double post.

posts: 2881 United Kingdom

Hi

Have a look at an existing modules in /modules/

damian


posts: 34

I looked in several at random, and couldn't find anything that used one. After your post I decided to go through the entire list top to bottom. First one in the list: mod-articles.php. It uses a parameter. redface

Example for others:

if (isset($module_params[ "type" ])) { $type = $module_params[ "type "]; } else { $type = ''; }

posts: 34
Ok, I can get parameters passed to my module, but not more than one. If multiples are possible, what is the seperator that I use on admin-modules screen. I have tried space, pipe, semicolon, comma. All no luck.

posts: 63 United Kingdom

Is it a ampersand?

Remember modules are just PHP sacripts which are included. The proper way to pass parameters to a php is obviousley

path/to/scriptname.pgp?param1&param2&param3

So perhaps seperating your parameters in the box with & signs would do it..

I just hope tiki doesn't escape this input.


posts: 34
Yup, that did it. var1=1&var2=2 works well. I guess somone picked this delimiter because of the url parameters, but being a module, parameters are not passed to it as part of the URL. All the data on tiki is stored in the database, includeing how all your modules are set up, and the parameters they have. Tiki pulls this data out and creates php vars and arrays of vars that the modules have access to when they are included; in this case module_params[].