Creating a Wiki Plugin is a great way to get started contributing to Tiki as plugins can stand alone and minimum PHP programming skills are needed.

Wiki plugins extend the function of wiki syntax with more specialized commands. Usually expressed in {curly brackets} plugins compact a chunk of PHP or HTML code into something that can be understood by non-programmers.

Here are all the current Wiki plugins:


Let's use and example where we want to create a plugin to allow text formatting in any font and size:

Copy to clipboard
{FONT(size=>20,face=>arial)} some text {FONT}

If a plugin doesn't require parameters, the syntax will be:

Copy to clipboard
{EXAMPLE()} content {EXAMPLE}

When tiki finds a plugin the engine will look at the plugin name and look for the file:

Copy to clipboard

Don't be too creative with plugin names. For instance, any number in a plugin names seems to make the plugin fail. A plugin name containing only alphabetical character will be valid.

For example:

Copy to clipboard

That file should be a PHP file defining both functions:

Copy to clipboard
function wikiplugin_font($data,$params) {}


Copy to clipboard
function wikiplugin_font_info() {}

Info function

The info function defines the plugin's parameters and is used by the PLUGINMANAGER plugin for documenting an individual plugin, so it is important to populate this function as completely and accurately as possible. In our example there are only two parameters, these will be face and size but they each have a number of 'settings'.
For example:

Copy to clipboard
function wikiplugin_font_info() { return array( 'name' => tra('Font'), 'documentation' => 'PluginFont', 'description' => tra('Create a an HTML (deprecated) font tag.'), 'tags' => array( 'basic' ), 'prefs' => array( 'wikiplugin_font' ), 'introduced' => 9, 'params' => array( 'size' => array( 'required' => false, 'name' => tra('Font size'), 'description' => tra('Choose font size in pixels. Enter numbers only'), 'filter' => 'digits', 'default' => '12', 'since' => '9.0', ), 'face' => array( 'required' => false, 'name' => tra('Font face'), 'description' => tra('Choose font face.'), 'filter' => 'alpha', 'default' => 'normal', 'since' => '9.0', ), ), ); }

Individual plugins may have parameters that need additional 'settings' but the settings above ie 'required', 'name', 'description', 'filter', 'default' (but only if 'required is false) and 'since', are the minimum number that should be set for every parameter.

 Don't forget to clear caches
Any change in this function should be followed with AdminTiki Cache/System Admin./temp/cache/ and reloading the page which contains the plugin.

Body function

The function receives the plugin content in $data and the parameters in the $params associative array. The function manipulates the content and must return a string with the HTML that will replace the plugin content when rendering the wiki page (it can be just text if no HTML markup is needed).

For example:

Copy to clipboard
function wikiplugin_example($data,$params) { extract($params, EXTR_SKIP); if(!isset($face)) { return ("<b>missing face parameter for plugin</b><br/>"); } if(!isset($size)) { return ("<b>missing size parameter for plugin</b><br/>"); } $ret = "<span style='font-face: $face; font-size: $size'>$data</span>"; return $ret; }

The return of your plugin will be wiki parsed. If you do not want it to be parsed again, you must enclose the value like this

Copy to clipboard
return ' '.$ret.' ';

Special Plugins

These aren't real plugins but, like plugins, use a slightly different curly braces syntax. Unlike plugins, you don't "close" them. e.g., use {maketoc} instead of {maketoc()}{maketoc}. These can also appear in template (.tpl) files.

PluginBanner Displays a banner. {banner zone=}. Set up banners via admin menu. Note that if you assign multiple banners to the same zone, missing parameter will pick a different banner in that zone each time (more or less) the page is refreshed.
PluginContent Displays dynamic content
PluginDraw Displays a drawing which is an image that can be modified via a Java applet. {draw name=}. name must be unique for the entire site. Requires "drawing" feature to be turned on via the admin menu. If the drawing doesn't exist, the page will display a button that will create the drawing.
PluginImg Displays an image {img src= height= width=}. Mimics the HTML img tag.
PluginMaketoc Displays an indented table of contents using !, !!, !!! headers. {maketoc}.
PluginRSS Displays an RSS feed. {rss id= max=}. Set up RSS feeds via admin menu (RSS Modules).
PluginTOC Displays a table of contents for the structure that the page belongs to.

Related docs

How to add an item on the toolbar by default (once you add a plugin, you likely want it to be easy for people to use in text areas)

For notes on the future of plugins (and modules) see Gadgets.

Related links