MediaWiki extensions manual
OOjs UI icon advanced.svg
Release status: unmaintained
Implementation MyWiki
Description Adds a simple random trick when editing a page.
Author(s) Bertrand Roussel (CoRfrtalk)
Latest version 1.0
MediaWiki 1.14+
PHP 5.2+
Database changes No
License No license specified
Download see below
Translate the EditPageTrick extension if it is available at translatewiki.net
Check usage and version matrix.

The EditPageTrick extension adds a random trick at the head of the editing page in a really easy way. Possible tricks are easily editable and are contained in a single page.



In order to make the extension works, you must create a page called 'EditTricks' in the MediaWiki namespace. This page contain all the tricks that will be shown randomly. Tricks are separated by the syntaxe '----'.

Tricks are a really easy way to highlight new syntaxes.
You can upload files on the wiki using the File namespace.
<pre>[[File: MyUploadedFile.pdf]]</pre>
Tricks are tricky.

Trick templateEdit

The tricks are rendered using a template called Trick.


  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/EditPageTrick/EditPageTrick.php";
  • Create the Trick template at page "Template:Trick" and put your template code in there. A really simple template would be something like this:
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.


if ( !defined( 'MEDIAWIKI' ) )
        die ();

$wgExtensionCredits['other'][] = array( 
        'name' => 'EditPageTrick', 
        'author' => 'Bertrand Roussel',
        'version' => '1.0',
        'url' => 'https://www.mediawiki.org/wiki/Extension:EditPageTrick',
        'description' => 'Adds a simple random trick when editing a page',

$wgHooks['EditPage::showEditForm:initial'][] = 'editPageTricks';

function editPageTricks($editPage) {
        global $wgOut;

        $trick = '';

        $title = Title::newFromText('EditTricks', NS_MEDIAWIKI);
        $article = new Article($title);

        $tricks = explode( '----', $article->getContent() );

        if( !empty($tricks) ) {
                $size = count($tricks);
                $trick = $tricks[rand(0, $size-1)];
                $editPage->editFormTextTop .= $wgOut->parse( '{{Trick|'.trim($trick).'}}' );

        return true;