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
In 1.36 and 1.37 this hook was modified to allow modifications to the personal urls menu that traditionally would be modified by Manual:Hooks/PersonalUrls. If you are modifying the personal menus and support is needed for < 1.36, you will need to use PersonalUrls hook.
Examples
[edit]Add a link to a menu
[edit]$wgHooks['SkinTemplateNavigation::Universal'][] = function ( $skinTemplate, &$links ) {
// add a new namespace tab
$links['namespaces']['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'] );
};