Manual:Tag extensions

What can you do with an extension
Using the extension mechanism it is possible to define custom XML style tags which can then be used in the Wiki editor like this: some text The text between the tags gets passed on to a PHP function you implement. The string returned from your function then gets inserted into the HTML output in place of the tags and text.

How to get started
WikiMedia extensions live in the extensions/ subdirectory of the WikiMedia install. First create a new file YourExtensionName.php in this folder and copy the following example code into it  some text 
 * 5) the function registered by the extension gets the text between the
 * 6) tags as input and can transform it into arbitrary HTML code.
 * 7) Note: The output is not interpreted as WikiText but directly
 * 8)       included in the HTML output. So Wiki markup is not supported.
 * 9) To activate the extension, include it from your LocalSettings.php
 * 10) with: include("extensions/ExampleExt.php");

function wfExampleExtension { global $wgParser; // register the extension with the WikiText parser // the first parameter is the name of the new tag. In this case it defines the tag ...    // the second parameter is the callback function for processing the text between the tags $wgParser->setHook( "example", "renderExample" ); }

// The callback function for converting the input text to HTML output function renderExample( $input ) {   $output = "&lt;pre&gt;Text passed into example extension: ". $input. "&lt;/pre&gt;"; return $output; } ?>

Now change the tag name, the function names and of course the functionality of the callback to your liking. Note that it might be better to first install and test the example extension (see next section) and only then start customizing it.

Installing the extension
All it takes is adding a single line to your LocalSettings.php file: include("extensions/YourExtensionName.php"); and you are ready to go. Go to the sandbox and see if it works.