Welcome, Registration, and other StartingPoints; TWiki history & Wiki style; All the docs...

TWiki Plugins

Add functionality to TWiki with readily available Plugins; create Plugins based on APIs


You can add Plugins to extend TWiki functionality, without altering the core code. A plug-in approach lets you:

  • add virtually unlimited features while keeping the main TWiki code compact and efficient;
  • heavily customize an installation and still do clean updates to new versions of TWiki;
  • rapidly develop new TWiki functions in Perl using the Plugin API.

Everything to do with TWiki Plugins - demos, new releases, downloads, development, general discussion - is available at TWiki.org, in the TWiki:Plugins web.

TWiki Plugins are developed and contributed by interested members of the community. Plugins are provided on an 'as is' basis; they are not a part of TWiki, but are independently developed and maintained.

Relevant links on TWiki.org:

See other types of extensions: TWikiAddOns, TWikiContribs, TWikiSkins

Installing Plugins

Each TWiki Plugin comes with its own documentation: step-by-step installation instructions, a detailed description of any special requirements, version details, and a working example for testing. Many Plugins have an install script that automates these steps for you.

Special Requirements: Some Plugins need certain Perl modules to be preinstalled on the host system. Plugins may also use other resources, like graphics, other modules, applications, and templates. You should be able to find detailed instructions in the Plugin's documentation.

Each Plugin has a standard release topic, located in the TWiki:Plugins web at TWiki.org. There's usually a number of other related topics, such as a developers page, and an appraisal page.

On-Site Pretesting

The recommended approach to testing new Plugins before making them public is to create a second local TWiki installation, and test the Plugin there. You can allow selected users access to the test area. Once you are satisifed that it won't compromise your main installation, you can install it there as well.

InstalledPlugins shows which Plugins are: 1) installed, 2) loading properly, and 3) what TWiki:Codev.PluginHandlers they invoke. Any failures are shown in the Errors section. The %FAILEDPLUGINS% 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:
time wget -qO /dev/null /twiki/bin/view/TWiki/AbcPlugin

TIP 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 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.

Plugin-Specific Settings

Plugins are usually configured by variables accessible though the 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 %<pluginname>_<var>%. For example, %RUBBERPLUGIN_SETTING% shows the value of SETTING in the RubberPlugin topic.

Listing Active Plugins

Plugin status variables let you list all active Plugins wherever needed.


On this TWiki site, the enabled Plugins are: SpreadSheetPlugin, ActionTrackerPlugin, AttachmentListPlugin, BreadCrumbsPlugin, CalendarPlugin, CommentPlugin, CompareRevisionsAddonPlugin, EditTablePlugin, FilterPlugin, FlexWebListPlugin, FootNotePlugin, GluePlugin, IfDefinedPlugin, InterwikiPlugin, JQueryPlugin, NatSkinPlugin, PreferencesPlugin, RedDotPlugin, RenderListPlugin, SlideShowPlugin, SmiliesPlugin, TablePlugin, TreeBrowserPlugin, TreePlugin, TwistyPlugin, VotePlugin, WysiwygPlugin.


  • SpreadSheetPlugin (any TWiki, 10197): Add spreadsheet calculation like "$SUM( $ABOVE() )" to TWiki tables and other topic text
  • ActionTrackerPlugin (21 May 2007, $Rev: 14969 (20 Sep 2007) $): Adds support for action tags in topics, and automatic notification of action statuses
  • AttachmentListPlugin (1.0.1, $Rev: 15921 (07 Dec 2007) $): Displays a formattable list of topic attachments, anywhere in a topic.
  • BreadCrumbsPlugin (v1.00, $Rev: 13657 (08 May 2007) $): A flexible way to display breadcrumbs navigation
  • CalendarPlugin (Dakar, 9113): Show a monthly calendar with highlighted events
  • CommentPlugin (Dakar, 11359): Allows users to quickly post comments to a page without an edit/preview/save cycle
  • CompareRevisionsAddonPlugin (Dakar, $Rev: 9808$):
  • EditTablePlugin (any TWiki, 11646): Edit TWiki tables using edit fields, date pickers and drop down boxes
  • FilterPlugin (1.40, $Rev: 15932 (07 Dec 2007) $): Substitute and extract information from content by using regular expressions
  • FlexWebListPlugin (v1.21, $Rev: 16132 (03 Jan 2008) $): Flexible way to display hierarchical weblists
  • FootNotePlugin (2.006): Footnotes are notes placed at the end of a topic.
  • GluePlugin (2.00, $Rev: 15708 (23 Nov 2007) $): Enable markup to span multiple lines
  • IfDefinedPlugin (v1.01, $Rev: 15157 (05 Oct 2007) $): Render content conditionally
  • InterwikiPlugin (Dakar, $Rev: 11935$): Link ExternalSite:Page text to external sites based on aliases defined in a rules topic
  • JQueryPlugin (v0.4, $Rev: 15608 (15 Nov 2007) $): jQuery JavaScript library for TWiki
  • NatSkinPlugin (3.00-pre17, $Rev: 15581 (13 Nov 2007) $): Supplements the bare bones NatSkin theme for TWiki
  • PreferencesPlugin (Dakar, 9839): Allows editing of preferences using fields predefined in a form
  • RedDotPlugin (1.40, $Rev: 16137 (03 Jan 2008) $): Renders edit-links as little red dots
  • RenderListPlugin (any TWiki, 1.034): Render bullet lists in a variety of formats
  • SlideShowPlugin (Any TWiki, $Rev: 12847$): Create web based presentations based on topics with headings.
  • SmiliesPlugin (Dakar, 8154): Render smilies as icons, like smile for  :-) or eek! for = :eek:=
  • TablePlugin (1.020, 12339): Control attributes of tables and sorting of table columns
  • TreeBrowserPlugin (v1.8): Renders a list as a collapsable/expandable tree.
  • TreePlugin (1.7): Dynamic generation of TWiki topic trees
  • TwistyPlugin (1.2.0, $Rev: 12154$): Twisty section JavaScript library to open/close content dynamically
  • VotePlugin (1.33, $Rev: 14312 (01 Jul 2007) $): Simple way to count votes
  • WysiwygPlugin (Dakar, 12422): Translator framework for Wysiwyg editors


SpreadSheetPlugin none
ActionTrackerPlugin none
AttachmentListPlugin none
BreadCrumbsPlugin none
CalendarPlugin none
CommentPlugin none
CompareRevisionsAddonPlugin none
EditTablePlugin none
FilterPlugin none
FlexWebListPlugin none
FootNotePlugin none
GluePlugin none
IfDefinedPlugin none
InterwikiPlugin none
JQueryPlugin none
NatSkinPlugin none
PreferencesPlugin none
RedDotPlugin none
RenderListPlugin none
SlideShowPlugin none
SmiliesPlugin none
TablePlugin none
TreeBrowserPlugin none
TreePlugin none
TwistyPlugin none
VotePlugin none
WysiwygPlugin none
This handler is deprecated - please check for updated versions of the plugins that use it!
27 plugins

The TWiki Plugin API

The Application Programming Interface (API) for TWiki Plugins provides the specifications for hooking into the core TWiki code from your external Perl Plugin module.

Available Core Functions

The TWikiFuncDotPm module (lib/TWiki/Func.pm) describes all the interfaces available to Plugins. Plugins should only use the interfaces described in this module.

ALERT! Note: If you use other core functions not described in Func.pm, you run the risk of creating security holes. Also, your Plugin will likely break and require updating when you upgrade to a new version of TWiki.

Predefined Hooks

In addition to TWiki core functions, Plugins can use predefined hooks, or callbacks, as described in the lib/TWiki/Plugins/EmptyPlugin.pm module.

  • All but the initPlugin are disabled. To enable a callback, remove DISABLE_ from the function name.

TWiki:Codev/StepByStepRenderingOrder helps you decide which rendering handler to use.

Hints on Writing Fast Plugins

  • Delay initialization as late as possible. For example, if your Plugin is a simple syntax processor, you might delay loading extra Perl modules until you actually see the syntax in the text.
  • For example, use an eval block like this:
    eval { require IPC::Run }
    return "<font color=\"red\">SamplePlugin: Can't load required modules ($@)</font>" if $@;
  • You can use a flag to avoid running the initialization twice
  • The TWiki:Plugins.PluginBenchmarkAddOn comes in handy to measure and fine-tune the performance of your Plugin

Plugin Version Detection

To eliminate the incompatibility problems bound to arise from active open Plugin development, a Plugin versioning system is provided for automatic compatibility checking.

  • All modules require a $VERSION='0.000' variable, beginning at 1.000.

  • The initPlugin handler should check all dependencies and return TRUE if the initialization is OK or FALSE if something went wrong.
    • The Plugin initialization code does not register a Plugin that returns FALSE (or that has no initPlugin handler).

  • $TWiki::Plugins::VERSION in the TWiki::Plugins module contains the TWiki Plugin API version, currently 1.11.
    • You can also use the %PLUGINVERSION{}% variable to query the Plugin API version or the version of installed Plugins.


  • 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
  • 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 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, you're ready to develop Plugins.

Creating the Perl Module

Copy file lib/TWiki/Plugins/EmptyPlugin.pm to <name>Plugin.pm. The EmptyPlugin.pm module contains mostly empty functions, so it does nothing, but it's ready to be used. Customize it. Refer to the Plugin API specs for more information.

If your Plugin uses its own modules and objects, you must include the name of the Plugin in the package name. For example, write Package MyFirstPlugin::Attrs; instead of just Package Attrs;. Then call it using:

use TWiki::Plugins::MyFirstPlugin::Attrs;
$var = MyFirstPlugin::Attrs->new();

Measuring and Improving the Plugin Performance

A high quality Plugin performs well. You can use the TWiki:Plugins.PluginBenchmarkAddOn to measure your TWiki:Plugins.PluginBenchmarks. The data is needed as part of the Documentation Topic.

See also Hints on Writing Fast Plugins.

Writing the Documentation Topic

The Plugin documentation topic contains usage instructions and version details. It serves the Plugin files as FileAttachments for downloading. (The doc topic is also included in the distribution package.) To create a documentation topic:

  1. Copy the Plugin topic template from TWiki.org. To copy the text, go to TWiki:Plugins/PluginPackage and:
    • enter the Plugin name in the "How to Create a Plugin" section
    • click Create
    • select all in the Edit box & copy
    • Cancel the edit
    • go back to your site to the TWiki web
    • In the GoBox enter your Plugin name, for example MyFirstPlugin, press enter and create the new topic
    • paste & save new Plugin topic on your site
  2. Customize your Plugin topic.
    • Important: In case you plan to publish your Plugin on TWiki.org, use Interwiki names for author names and links to TWiki.org topics, such as TWiki:Main/TWikiGuest. This is important because links should work properly in a Plugin topic installed on any TWiki, not just on TWiki.org.
  3. Document the performance data you gathered while measuring the performance
  4. Save your topic, for use in packaging and publishing your Plugin.

OUTLINE: Doc Topic Contents
Check the Plugins web on TWiki.org for the latest Plugin doc topic template. Here's a quick overview of what's covered:

Syntax Rules: <Describe any special text formatting that will be rendered.>"

Example: <Include an example of the Plugin in action. Possibly include a static HTML version of the example to compare if the installation was a success!>"

Plugin Settings: <Description and settings for custom Plugin %VARIABLES%, and those required by TWiki.>"

  • Plugins Preferences <If user settings are needed, explain... Entering values works exactly like TWikiPreferences and WebPreferences: six (6) spaces and then:>"
    • Set <EXAMPLE = value added>

Plugin Installation Instructions: <Step-by-step set-up guide, user help, whatever it takes to install and run, goes here.>"

Plugin Info: <Version, credits, history, requirements - entered in a form, displayed as a table. Both are automatically generated when you create or edit a page in the TWiki:Plugins web.>"

Packaging for Distribution

The TWiki:Plugins.BuildContrib is a powerful build environment that is used by the TWiki project to build TWiki itself, as well as many of the Plugins. You don't have to use it, but it is highly recommended!

If you don't want (or can't) use the BuildContrib, then a minimum Plugin release consists of a Perl module with a WikiName that ends in Plugin, ex: MyFirstPlugin.pm, and a documentation page with the same name(MyFirstPlugin.txt).

  1. Distribute the Plugin files in a directory structure that mirrors TWiki. If your Plugin uses additional files, include them all:
    • lib/TWiki/Plugins/MyFirstPlugin.pm
    • data/TWiki/MyFirstPlugin.txt
    • pub/TWiki/MyFirstPlugin/uparrow.gif [a required graphic]
  2. Create a zip archive with the Plugin name (MyFirstPlugin.zip) and add the entire directory structure from Step 1. The archive should look like this:
    • lib/TWiki/Plugins/MyFirstPlugin.pm
    • data/TWiki/MyFirstPlugin.txt
    • pub/TWiki/MyFirstPlugin/uparrow.gif

Publishing for Public Use

You can release your tested, packaged Plugin to the TWiki community through the TWiki:Plugins web. All Plugins submitted to TWiki.org are available for download and further development in TWiki:Plugins/PluginPackage.

Publish your Plugin by following these steps:

  1. Post the Plugin documentation topic in the TWiki:Plugins/PluginPackage:
    • enter the Plugin name in the "How to Create a Plugin" section, for example MyFirstPlugin
    • paste in the topic text from Writing the Documentation Topic and save
  2. Attach the distribution zip file to the topic, ex: MyFirstPlugin.zip
  3. Link from the doc page to a new, blank page named after the Plugin, and ending in Dev, ex: MyFirstPluginDev. This is the discussion page for future development. (User support for Plugins is handled in TWiki:Support.)
  4. Put the Plugin into the SVN repository, see TWiki:Plugins/ReadmeFirst (optional)

NEW Once you have done the above steps once, you can use the BuildContrib to upload updates to your Plugin.

Thank you very much for sharing your Plugin with the TWiki community smile

Recommended Storage of Plugin Specific Data

Plugins sometimes need to store data. This can be Plugin internal data such as cache data, or data generated for browser consumption such as images. Plugins should store data using TWikiFuncDotPm functions that support saving and loading of topics and attachments.

Plugin Internal Data

You can create a Plugin "work area" using the TWiki::Func::getWorkArea() function, which gives you a persistant directory where you can store data files. By default they will not be web accessible. The directory is guaranteed to exist, and to be writable by the webserver user. For convenience, TWiki::Func::storeFile() and TWiki::Func::readFile() are provided to persistently store and retrieve simple data in this area.

Web Accessible Data

Topic-specific data such as generated images can be stored in the topic's attachment area, which is web accessible. Use the TWiki::Func::saveAttachment() function to store the data.

Recommendation for file name:

  • Prefix the filename with an underscore (the leading underscore avoids a nameclash with files attached to the same topic)
  • Identify where the attachment originated from, typically by including the Plugin name in the file name
  • Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
  • Example: _FooBarPlugin_img123.gif

Web specific data can be stored in the Plugin's attachment area, which is web accessible. Use the TWiki::Func::saveAttachment() function to store the data.

Recommendation for file names in Plugin attachment area:

  • Prefix the filename with an underscore
  • Include the name of the web in the filename
  • Use only alphanumeric characters, underscores, dashes and periods to avoid platform dependency issues and URL issues
  • Example: _Main_roundedge-ul.gif

Maintaining Plugins

Discussions and Feedback on Plugins

Each published Plugin has a Plugin development topic on TWiki.org. Plugin development topics are named after your Plugin and end in Dev, such as MyFirstPluginDev. The Plugin development topic is a great resource to discuss feature enhancements and to get feedback from the TWiki community.

Maintaining Compatibility with Earlier TWiki Versions

The Plugin interface (TWikiFuncDotPm functions and handlers) evolve over time. TWiki 4.0 introduced new API functions to address the needs of Plugin authors. It also deprecated some functions. Some Plugins written for earlier TWiki releases using unofficial TWiki internal functions no longer work on the TWiki 4.0 codebase. All this means that some Plugins need to be updated to work on the TWiki 4.0 codebase.

Organizations typically do not upgrade to the latest TWiki for many months. However, many administrators still would like to install the latest versions of a Plugin on their older TWiki installation. This need is fullfilled if Plugins are maintained in a compatible manner.

TIP Tip: Plugins can be written to be compatible with older and newer TWiki releases. This can be done also for Plugins using unofficial TWiki internal functions of an earlier release that no longer work on the latest TWiki codebase. TWiki:TWiki.TWikiPluginsSupplement#MaintainPlugins has more.

Handling deprecated functions

From time-to-time, the TWiki developers will add new functions to the interface (either to TWikiFuncDotPm, or new handlers). Sometimes these improvements mean that old functions have to be deprecated to keep the code manageable. When this happens, the deprecated functions will be supported in the interface for at least one more TWiki release, and probably longer, though this cannot be guaranteed.

When a plugin defines deprecated handlers, a warning will be shown in the list generated by %FAILEDPLUGINS%. Admins who see these warnings should check TWiki.org and if necessary, contact the plugin author, for an updated version of the plugin.

Updated plugins may still need to define deprecated handlers for compatibility with old TWiki versions. In this case, the plugin package that defines old handlers can suppress the warnings in %FAILEDPLUGINS%.

This is done by defining a map from the handler name to the TWiki::Plugins version in which the handler was first deprecated. For example, if we need to define the endRenderingHandler for compatibility with TWiki::Plugins versions before 1.1, we would add this to the plugin:

package TWiki::Plugins::SinkPlugin;
use vars qw( %TWikiCompatibility );
$TWikiCompatibility{endRenderingHandler} = 1.1;
If the currently-running TWiki version is 1.1 or later, then the handler will not be called and the warning will not be issued. TWiki with versions of TWiki::Plugins before 1.1 will still call the handler as required.

Related Topics: DeveloperDocumentationCategory, AdminDocumentationCategory, TWiki:TWiki.TWikiPluginsSupplement

-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.AndreaSterbini, TWiki:MainMikeMannix, TWiki:CrawfordCurrie



Webs Webs

r32 - 06 Jan 2007 - 09:49:24 - TWikiContributor
This site is powered by the TWiki collaboration platform.
All material on this collaboration platform is the property of the contributing authors.
All material marked as authored by Eben Moglen is available under the license terms CC-BY-SA version 4.
Syndicate this site RSSATOM