NB: these are rough notes, and could do with checking and/or tidying up from someone who understands plugins better
If for instance you want to give users access to certain settings/configurations that your plugin might have, there are two ways of achieving this:
1. A Kohana config file
Create a config folder within your plugin folder. Within this folder create a config file with a unique file name example: [my_plugin_name].php. This configuration file must adhere to Kohana config file standards.
This setting will then be available anywhere in the Ushahidi application using
2.Ushahidi Admin Console
This method requires you to create a separate database table to store your settings in.
You need to create one table and four new files to add your admin console. Please use the method described in [[How to Write A Plugin]] to create your table. The other things you need to add are:
- A new table in libraries/myplugin_install.php where [my_plugin] is the unique name of your plugin.
- A new model in models/myplugin_settings.php
- A new controller called [my_plugin]_settings.php.
- A new view in views/myplugin/admin/myplugin_settings.php
The Ushahidi system will automatically detect this controller and will display a [Settings] link to this controller from the plugin list in the admin console. Once you create all these files, the controller has all the functionality necessary to save and update settings in your my_plugin settings table.
First, create a database table for your settings. You put this into libraries/myplugin_install.php. For example,
Then create a model that matches that database table. You put this into models/myplugin_settings.php
Then create an admin controller in file controllers/admin/myplugin_settings.php To use the settings values, add this into your controller:
Then create an admin view in views/myplugin/admin/myplugin_settings.php. Add this into your view:
Now you can go to the settings page and set these values.