Loading...
 

Code Howto: Create a Wiki 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.

For advanced plugins that may speed development time see - Create a Zend Wiki Plugin.

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

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:

lib/wiki-plugins/wikiplugin_font.php


That file should be a PHP file defining both functions:

function wikiplugin_font($data,$params) {}

and

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:

wikiplugin_font_info()
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 ‘’Admin’’ → ‘’Tiki 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:

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 ' §c7e3423d21419e7f9db0183556ec53ea§ ';

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)

Related links

alias

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.

Accessibility (WAI & 508)
Accounting 7.x
Administration
Ajax 2.x
Articles & Submissions
Backlinks
Banner
Batch 6.x
BigBlueButton audio/video/chat/screensharing (5.x)
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution 2.x
Cookie
Copyright
Credits 6.x
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs 8.x
DogFood
Draw 7.x
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Group
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping 3.x
Mobile Tiki and Voice Tiki
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Payment 5.x
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Score
Search engine optimization (SEO)
Search
Security
Semantic links 3.x
Share
Shopping Cart 5.x
Shoutbox
Site Identity
Slideshow
Smarty Template
Social Networking
Spam protection (Anti-bot CATPCHA)
Spellcheck
Spreadsheet
Staging and Approval
Stats
Survey
Syntax Highlighter (Codemirror)
Tablesorter
Tags 2.x
Task
Tell a Friend, alert + Social Bookmarking
Terms and Conditions
Theme
TikiTests 2.x
Timesheet
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
WebHelp
Webmail and Groupmail
WebServices 3.x
Wiki 3D
Wiki History, page rename, etc
Wiki plugins extends basic syntax
Wiki syntax text area, parser, etc
Wiki structure (book and table of content)
Workspace and perspectives 4.x
WYSIWTSN 4.x
WYSIWYCA
WYSIWYG 2.x
XMLRPC




Useful Tools