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.

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: https://gitlab.com/tikiwiki/tiki/-/tree/master/lib/wiki-plugins

Example

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
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:

Copy to clipboard
lib/wiki-plugins/wikiplugin_font.php


That file should be a PHP file defining both functions:

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

and

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:

wikiplugin_font_info()
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

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
Administration
Ajax
Articles & Submissions
Backlinks
Banner
Batch
BigBlueButton audio/video/chat/screensharing
Blog
Bookmark
Browser Compatibility
Calendar
Category
Chat
Comment
Communication Center
Consistency
Contacts Address book
Contact us
Content template
Contribution
Cookie
Copyright
Credits
Custom Home (and Group Home Page)
Database MySQL - MyISAM
Database MySQL - InnoDB
Date and Time
Debugger Console
Diagram
Directory (of hyperlinks)
Documentation link from Tiki to doc.tiki.org (Help System)
Docs
DogFood
Draw -superseded by Diagram
Dynamic Content
Preferences
Dynamic Variable
External Authentication
FAQ
Featured links
Feeds (RSS)
File Gallery
Forum
Friendship Network (Community)
Gantt
Group
Groupmail
Help
History
Hotword
HTML Page
i18n (Multilingual, l10n, Babelfish)
Image Gallery
Import-Export
Install
Integrator
Interoperability
Inter-User Messages
InterTiki
jQuery
Kaltura video management
Kanban
Karma
Live Support
Logs (system & action)
Lost edit protection
Mail-in
Map
Menu
Meta Tag
Missing features
Visual Mapping
Mobile
Mods
Modules
MultiTiki
MyTiki
Newsletter
Notepad
OS independence (Non-Linux, Windows/IIS, Mac, BSD)
Organic Groups (Self-managed Teams)
Packages
Payment
PDF
Performance Speed / Load / Compression / Cache
Permission
Poll
Profiles
Quiz
Rating
Realname
Report
Revision Approval
Scheduler
Score
Search engine optimization (SEO)
Search
Security
Semantic links
Share
Shopping Cart
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
Task
Tell a Friend
Terms and Conditions
Theme
TikiTests
Federated Timesheets
Token Access
Toolbar (Quicktags)
Tours
Trackers
TRIM
User Administration
User Files
User Menu
Watch
Webmail and Groupmail
WebServices
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
WYSIWTSN
WYSIWYCA
WYSIWYG
XMLRPC
XMPP




Useful Tools