MediaWiki Extending

From virtualMV2015wiki
Revision as of 17:27, 14 January 2015 by Hesperides (Talk | contribs) (1 revision imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Media wiki can be extended in several ways

  1. Client-Side JavaScript
  2. Templates
  3. Extensions
  4. Widgets
  5. Miscellaneous Tools

The MediaWiki codebase contains various "hooks" using callback functions to add additional code in an extensible way. This allows developers to write extensions without modifying the core or having to submit their code for review. Installing an extension typically consists of adding a line to the configuration file, though in some cases additional changes such as database updates are required. Wikipedia:MediaWiki(2009)[1]


Media wiki allows a special page MediaWiki:Common.js that is loaded every time a page is displayed. It is not editible by users and is created by the system admin.

JavaScript inpage

In here I'd love to include a basic javascript that demonstrates how it can be included on a web page, something like..

<script type="text/javascript">
  function fnHello() {
    <input type="button" onclick="fnHello()" value="Call function" />

Reference: wikibooks:MediaWiki Developer's Handbook/Add JavaScript (2009)[2] - really cryptic and really no help at all yet :)

However Media wiki describes an extension (Extension:Javascript, 2009, June 27)[3] which I must try (I want to add a text size JavaScript element).


<references />
<div style="font-family: menu,Arial; border: 1px solid #0000FF;font-size: x-small; background-color: #E6F2FF;">
 from {{fullurl:{{PAGENAME}}}}</div>

and call it at the bottom of a wiki page using



My templates Specify an APA reference at the footer of each page:


Extensions usually are implemented in two parts

  1. First, some additional php files need to be uploaded to the server (that use wikiMedia hooks) to intercept the code and do the special things you want to do (e.g. GeSHI formats programming code using a code tag, cite allows for the ref tag to be used on a wiki page)
  2. Next a line of code is added to LocalSettings.php (on the Server)
  3. Finally the tags are added to the wiki page to call the new feature.



  • Cite extension (Arnfjörð Bjarmason,2009)[4] - adds two parser hooks <ref> and <reference /> to add citations to wiki pages.
  • GeSHI extension (Vibber, Starling, & Church (2009).[5]


Widgets extension allows adding widgets to wiki by just creating pages in Widget namespace. (MediaWiki:Extension:Widgets, 2009)[6]. For the widgets to work, the widget extension (some additional php code) must be installed on your server first. As there is potential for unauthorised access to your data, permission to create a widget (in the widget namespace) is set in the LocalSettings file)

The cool thing about a widget is that you can extend Media Wiki inside the wiki rather than creating additional PHP code to upload separately to the server.


  • YouTube widget (Koren, 2008)[7] - allows you to add YouTube video player to your wiki page

Miscellaneous tools


  1. Wikipedia:MediaWiki(2009) Media Wiki: Customisation. Retrieved June 6, 2009 from
  2. wikibooks:MediaWiki Developer's Handbook/Add JavaScript (2009) MediaWiki Developer's Handbook/Add JavaScript. Retrieved June 6, 2009 from's_Handbook/Add_JavaScript
  3. Extension:Javascript. (2009, June 27). MediaWiki, The Free Wiki Engine. Retrieved 11:24, October 7, 2009 from
  4. Arnfjörð Bjarmason, Æ. (2009) Extension:Cite/Cite.php, MediaWiki Retrieved June 6, 2009 from
  5. Vibber, B., Starling, T., & Church, R. (2009). Extension:SyntaxHighlight GeSHi, MediaWiki. Retrieved June 6, 2009 from
  6. MediaWiki:Extension:Widgets (2009) Extension:Widgets. Retrieved June 6, 2009 from
  7. Koren, Y. (2008) Widget:YouTube. Retrieved June 6, 2009 from


Verhaart, M. (2018). MediaWiki Extending. Retrieved October 21, 2018, from