The special page file

The body file (in this example, named <tvar|SpecialMyExtension>SpecialMyExtension.php</>) should contain a subclass of SpecialPage (or one of its subclasses).</translate> <translate>It will be loaded automatically when the special page is requested.</translate> <translate>This example implements the subclass SpecialMyExtension:</translate>

class SpecialMyExtension extends SpecialPage {
	function __construct() {
		parent::__construct( 'MyExtension' );
	function execute( $par ) {
		$request = $this->getRequest();
		$output = $this->getOutput();
		# <translate>Get request data from, e.g.</translate>
		$param = $request->getText( 'param' );
		# <translate>Do stuff</translate>
		# ...
		$wikitext = 'Hello world!';
		$output->addWikiText( $wikitext );

<translate>You need the <tvar|conduct>__construct()</> constructor because its first parameter names your special page.

<tvar|execute>execute()</> is the main function that is called when a special page is accessed.</translate> <translate>The function overloads the function <tvar|SpecialPage>SpecialPage::execute()</>.</translate> <translate>It passes a single parameter <tvar|par>$par</>, the subpage component of the current title.</translate> <translate>For example, if someone follows a link to <tvar|blah>Template:Ll</>, <tvar|par1>$par</> will contain "blah".

Wikitext and HTML output should normally be run via $wgOut — do not use 'print' or 'echo' directly when working within the wiki's user interface.

However if you're using your special page as an access point to custom XML or binary output, see <tvar|takingoveroutput>Template:Ll</>.</translate>


Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.