< MediaWiki Developer's Handbook
This will show you how to create a special page.
MySpecialPage.php
<?php
if (!defined("MEDIAWIKI")) {
die("not a valid entry point!");
}
$wgExtensionCredits['specialpage'][] = array (
'name' => 'My Special Page!',
'author' => 'Me',
'url' => 'http://en.wikibooks.org/',
'description' => 'A cool special page',
'version' => '1.2.3',
);
$wgAutoloadClasses['MySpecialPage'] = $dir . "MySpecialPage_body.php";
$wgSpecialPages['MySpecialPage'] = 'MySpecialPage.php';
This file registers the special page.
MySpecialPage_body.php
<?php
class MySpecialPage extends SpecialPage {
function __construct() {
parent::__construct();
}
function execute($par) {
global $wgOut;
mt_srand(time());
$d = str(mt_rand(1, 10));
$output = "Hello! Your lucky number is '''$d'''!";
$wgOut->addWikiText($output);
}
}
This is the special page itself. It should say something like Hello! "Your lucky number is 3"! {{:MediaWiki Developer's Handbook/Navigation}}
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.