Manual:Hooks/SpecialPage initList

From MediaWiki.org
Jump to: navigation, search
SpecialPage_initList
Available from version 1.7.0
permits filtering of the list of special pages enabled for the system

Define function:
public static function onSpecialPage_initList( &$aSpecialPages ) { ... }

Attach hook:
$wgHooks['SpecialPage_initList'][] = 'MyExtensionHooks::onSpecialPage_initList';
Called from: SpecialPage.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:SpecialPage_initList extensions.


[edit] Use cases

MediaWiki installations use the SpecialPage_initList hook when they want to add to or remove pages from the special page list. They can use this to:

  • dynamically add special pages from a database or other resource
  • remove undesirable built-in special pages from the default list
  • enable context dependent list of special pages - e.g. lists that depend on current server load, user's access method (local host, VPN, public internet)
  • replace the default class associated with a special page with a custom subclass
  • limit access to special pages based on user identity even in cases where the special page is not permissions aware

[edit] Background

A special page is a "virtual" MediaWiki article. Instead of being loaded from a file or database like a normal MediaWiki page, its content is generated on the fly using PHP code.

By default, MediaWiki builds the list of special pages from two sources: a list of builtin special pages hard coded into the MediaWiki core and the configuration variable $wgSpecialPages. As a final step, MediaWiki passes the default list to all the functions attached to the SpecialPage_initList.

[edit] Usage

Functions attached to this hook add and remove elements from $aSpecialPages. This array has the same structure as $wgSpecialPages.

The hook function should return true so as not to interfere with other functions that might be attached to this hook.

Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox