[[%FAILEDPLUGINS%|Main/VarFAILEDPLUGINS]]
variable can be used to debug failures. You may also want to check your webserver error log and the various TWiki log files.
### Some Notes on Plugin Performance
The performance of the system depends to some extent on the number of Plugins installed and on the Plugin implementation. Some Plugins impose no measurable performance decrease, some do. For example, a Plugin might use many Perl libraries that need to be initialized with each page view (unless you run mod\_perl). You can only really tell the performance impact by installing the Plugin and by measuring the performance with and without the new Plugin. Use the TWiki:Plugins.PluginBenchmarkAddOn, or test manually with the Apache `ab` utility. Example on Unix:%BR% `time wget -qO /dev/null http://www.dementia.org/twiki/view/TWiki/AbcPlugin`
%T% If you need to install an "expensive" Plugin, but you only need its functionality only in a subset of your data, you can disable it elsewhere by defining the %DISABLEDPLUGINS% TWiki variable.
Define `DISABLEDPLUGINS` to be a comma-separated list of names of plugins to disable. Define it in Main.TWikiPreferences to disable those plugins everywhere, in the WebPreferences topic to disable them in an individual web, or in a topic to disable them in that topic. For example,
* Set DISABLEDPLUGINS = SpreadSheetPlugin, EditTablePlugin
## Managing Installed Plugins
Some Plugins require additional settings or offer extra options that you have to select. Also, you may want to make a Plugin available only in certain webs, or temporarily disable it. And may want to list all available Plugins in certain topics. You can handle all of these management tasks with simple procedures:
### Enabling Plugins
Plugins can be enabled and disabled with the [configure](http://www.dementia.org/twiki/configure) script. An installed Plugin needs to be enabled before it can be used.
### Plugin Evaluation Order
By default, TWiki executes Plugins in alphabetical order on Plugin name. It is possible to change the order, for example to evaluate database variables before the speadsheet CALCs. This can be done with `{PluginsOrder}` in the Plugins section of [configure](http://www.dementia.org/twiki/configure).
### Plugin-Specific Settings
Plugins are usually configured by variables accessible though the [configure](http://www.dementia.org/twiki/configure) interface, but in some cases (usually older plugins) TWiki preferences are used. If a TWiki variable is defined in a Plugin topic e.g:
- Set SETTING = Create dynamic foo bar reports
Then these settings can be retrieved as preferences variables like `%Plugin | Errors |
---|---|
[[TWiki/SpreadSheetPlugin]] | Plugins: could not fully register SpreadSheetPlugin, no plugin topic |
[[TWiki/CommentPlugin]] | Plugins: could not fully register CommentPlugin, no plugin topic |
[[TWiki/EditTablePlugin]] | Plugins: could not fully register EditTablePlugin, no plugin topic |
[[TWiki/InterwikiPlugin]] | Plugins: could not fully register InterwikiPlugin, no plugin topic |
[[TWiki/PreferencesPlugin]] | Plugins: could not fully register PreferencesPlugin, no plugin topic |
[[TWiki/SlideShowPlugin]] | Plugins: could not fully register SlideShowPlugin, no plugin topic |
[[TWiki/SmiliesPlugin]] | Plugins: could not fully register SmiliesPlugin, no plugin topic |
[[TWiki/TablePlugin]] | Plugins: could not fully register TablePlugin, no plugin topic |
[[TWiki/TwistyPlugin]] | Plugins: could not fully register TwistyPlugin, no plugin topic |
Handler | Plugins |
---|---|
beforeCommonTagsHandler | PreferencesPlugin TwistyPlugin |
beforeSaveHandler | CommentPlugin |
commonTagsHandler | SpreadSheetPlugin CommentPlugin EditTablePlugin SlideShowPlugin SmiliesPlugin |
initPlugin | SpreadSheetPlugin CommentPlugin EditTablePlugin InterwikiPlugin PreferencesPlugin SlideShowPlugin SmiliesPlugin TablePlugin TwistyPlugin |
postRenderingHandler | EditTablePlugin PreferencesPlugin TwistyPlugin |
preRenderingHandler | InterwikiPlugin SmiliesPlugin TablePlugin |
[[%PLUGINVERSION{}%|Main/VarPLUGINVERSION]]
variable to query the Plugin API version or the version of installed Plugins.
### Security
- Badly written Plugins can open huge security holes in TWiki. This is especially true if care isn't taken to prevent execution of arbitrary commands on the server.
- Don't allow sensitive configuration data to be edited by users. it is better to add sensitive configuration options to the `%TWiki::cfg` hash than adding it as preferences in the Plugin topic
- See TWiki:Plugins.MailInContrib for an example of this
- TWiki:Plugins.BuildContrib can help you with this
- Always use the TWiki::Sandbox to execute commands.
- Always audit the Plugins you install, and make sure you are happy with the level of security provided. While every effort is made to monitor Plugin authors activities, at the end of the day they are uncontrolled user contributions.
## Creating Plugins
With a reasonable knowledge of the Perl scripting language, you can create new Plugins or modify and extend existing ones. Basic plug-in architecture uses an Application Programming Interface (API), a set of software instructions that allow external code to interact with the main program. The [[TWiki Plugin API|Main/WebHome#PluginAPI]] Plugins by providing a programming interface for TWiki.
### Anatomy of a Plugin
A basic TWiki Plugin consists of two elements:
- a Perl module, ex: `MyFirstPlugin.pm`
- a documentation topic, ex: `MyFirstPlugin.txt`
The Perl module can be a block of code that connects with TWiki alone, or it can include other elements, like other Perl modules (including other Plugins), graphics, TWiki templates, external applications (ex: a Java applet), or just about anything else it can call. In particular, files that should be web-accessible (graphics, Java applets ...) are best placed as attachments of the `MyFirstPlugin` topic. Other needed Perl code is best placed in a `lib/TWiki/Plugins/MyFirstPlugin/` directory.
The Plugin API handles the details of connecting your Perl module with main TWiki code. When you're familiar with the [[Plugin API|Main/WebHome#PluginAPI]], you're ready to develop Plugins.
### Creating the Perl Module
Copy file `lib/TWiki/Plugins/EmptyPlugin.pm` to `