development:misc:mediawiki_pkugin

Simple MediaWiki plugin

Want to write your own MediaWiki plugin? This is a simple 'Hello World' example. Once you get this, there's no limit

First create a folder for your plugin in /lib/plugins folder

/var/www/lib/plugins/myplugin

Now create a file plugin.info.txt containing the following text

base myplugin
author your name
email your email
date 2013-12-20
name plugin name with out spaces
desc plugin name with spaces
url support url

Create a syntax subfolder

/var/www/lib/plugins/myplugin/syntax

and create a php file with the following code

/**
* DokuWiki Plugin myplugin (Syntax Component)
*
* @license 
* @author 
*/
// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();
if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
require_once DOKU_PLUGIN.'syntax.php';
class syntax_plugin_myplugin_test extends DokuWiki_Syntax_Plugin {
function getType() {
return 'substition';
}
function connectTo($mode) {
$this->Lexer->addSpecialPattern('<myplugin>',$mode,'plugin_myplugin_test');
}
function render($mode, &$renderer, $data) {
if($mode != 'xhtml') return false;
$ren{erer->doc .= "Hello world!";
return true;
}
}
?>

Now you can start using your plugin by adding '<myplugin>' inside DokuWiki document (which will be replaced by your custom html from the plugin)

Enter your comment:
219 -0 = 
 
  • development/misc/mediawiki_pkugin.txt
  • Last modified: 2019/10/31 09:04
  • by 127.0.0.1