Fullscreen
[Show/Hide Right Column]

Close
noteNote
This page is to document "what Tiki should do". For feature documentation (what Tiki does), please see corresponding page on doc site

Print

Create a Plugin

Create a Plugin

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.


Example

Let's use and example where we want to create a plugin to allow text formatting in any font and size:
{FONT(size=>20,face=>arial)} some text {FONT}

If a plugin doesn't require parameters, the syntax will be:
{EXAMPLE()} content {EXAMPLE}

When tiki finds a plugin the engine will look at the plugin name and look for the file:
lib/wiki-plugins/wikiplugin_name.php

For example:
lib/wiki-plugins/wikiplugin_font.php

That file should be a PHP file defining the function:
function wikiplugin_font($data,$params) {}

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:
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
return ' ~np~'.$ret.' ';~/np~


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



Page last modified on Saturday 20 August, 2011 20:43:17 UTC

Search Wishes (subject only) [toggle]

Keywords

The following is a list of keywords that should serve as hubs for navigation within the Tiki development and should correspond to documentation keywords.

Each feature in Tiki has a wiki page which regroups all the bugs, requests for enhancements, etc. It is somewhat a form of wiki-based project management. You can also express your interest in a feature by adding it to your profile. You can also try out the Dynamic filter.