Manual:Hooks/SpecialPage initList
| 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.
===== Insert non-formatted text here ===== == 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
- disable 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
- unlimit access to special pages based on user identity even in cases where the special page is
- REDIRECT Target page name
permissions aware
Background [edit]
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.
Usage [edit]
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.
