Manual:Hooks/SkinTemplateNavigation::Universal
Appearance
| SkinTemplateNavigation::Universal | |
|---|---|
| Available from version 1.18.0 (r79358, CodeReview archive) Called on both content and special pages after variants have been added | |
| Define function: | public static function onSkinTemplateNavigation_Universal( SkinTemplate $skinTemplate, array &$links ) { ... }
|
| Attach hook: | In extension.json:
{
"Hooks": {
"SkinTemplateNavigation::Universal": "MediaWiki\\Extension\\MyExtension\\Hooks::onSkinTemplateNavigationUniversal"
}
}
|
| Called from: | File(s): skins/SkinTemplate.php |
| Interface: | SkinTemplateNavigation__UniversalHook.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:SkinTemplateNavigation::Universal extensions.
Details
[edit]- $skinTemplate: SkinTemplate object
- &$links: Structured array of navigation links. Note the keys in the menu vary and depend on what the skin supports. You can either call Skin::supportsMenu or isset to check menus are supported before modifying. The table below references the currently available menus derived from Skin::buildContentNavigationUrlsInternal (last updated Feb 2026)
| Template key | Data type | Usage | Available in MediaWiki version |
|---|---|---|---|
| languages | PortletData | Must be used if your skin supports languages | 1.36 |
| user-interface-preferences | PortletData | Can be used to allow extensions to surface settings controls outside the context of Special:Preferences. | 1.37 |
| user-page | PortletData | Should be used to render a link to the user's user page and user talk page. | 1.37 |
| user-menu | PortletData | Should be used to render links personal to a user e.g. their user contributions page and sandbox. | 1.37 |
| notifications | PortletData | Should be used to render user notifications e.g. support Echo | 1.37 |
| associated-pages | PortletData | Must be used to provide access to the discussion page and associated pages with special pages. | 1.43 |
| views | PortletData | Must be used to provide access to the edit and history links | 1.36 |
| actions | PortletData | Must be used to provide access to admins to protect, delete and move actions. | 1.36 |
| variants | PortletData | Must be used if your skin supports language variants | 1.36 |
Examples
[edit]Add a link to a menu
[edit]$wgHooks['SkinTemplateNavigation::Universal'][] = function ( $skinTemplate, &$links ) {
// add a new namespace tab
$links['associated-pages']['my_namespace'] = [
'class' => '',
'href' => '#/SkinTemplateNavigationLocalSettings.php',
'text' => 'SkinTemplateNavigationTab',
];
// add a new action
$links['actions']['my_action'] = [
'class' => '',
'href' => '#/SkinTemplateNavigationLocalSettings.php',
'text' => 'SkinTemplateNavigation action',
];
// add a new view
$links['views']['my_view'] = [
'class' => '',
'href' => '#/SkinTemplateNavigationLocalSettings.php',
'text' => 'SkinTemplateNavigation view',
];
};
Disable create account/login links on a fishbowl wiki
[edit]$wgHooks['SkinTemplateNavigation::Universal'][] = function ( $skinTemplate, &$links ) {
unset( $links['user-menu']['createaccount'] );
unset( $links['user-menu']['login'] );
unset( $links['user-menu']['login-private'] );
unset( $links['user-menu']['anoncontribs'] );
};