Skin:Minerva Neue/Hooks/MobileMenu

Warning Warning: This is scheduled for deprecation in 1.38 after which you will be able to use Manual:Hooks/SkinTemplateNavigation::Universal
MobileMenu
Available from version master (Gerrit change 260948)
Allows other extensions to add or override items of the mobile menu (hamburger menu) and some other toolbars.
Define function:
public static function onMobileMenu( $name, \MediaWiki\Minerva\Menu\Group &$group ) { ... }
Attach hook:
$wgHooks['MobileMenu'][] = 'MyExtensionHooks::onMobileMenu';
Called from:File(s): Minerva Neue /

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

Allows other extensions to add or override items of the mobile menu (hamburger menu).

Details

edit
  • $name: The toolbar or menu section name which $menu represents. Currently the hook will be called with the following names (note that some of these will be missing when not applicable, not allowed etc):
    • discovery: top section of the hamburger menu; by default contains Home, Random, and Nearby if the relevant extension is installed
    • personal: second section of the hamburger menu, when AMC is not enabled; by default Login/Logout, Watchlist, Contributions
    • sitetools: second section of the hamburger menu, when AMC is enabled; by default Recent changes, Special pages, Community portal
    • sitelinks: small links at the bottom of the hamburger menu, by default About and Disclaimers (note there is no way to alter or expand the part of the menu between this and sitetools, which contains the link to settings)
    • user separate toolbar accessible next to notifications, only when AMC is enabled; by default User page, Talk, Sandbox, Watchlist, Contributions, Login/Logout
    • pageactions.toolbar common page tools, on top of the content; by default Language, Watch, History, Edit
    • pageactions.overflow less common page tools (accessible with a dropdown next to the common ones, only when AMC is enabled); by default Page information, Permanent link, What links here, Wikidata item, Cite page, Download PDF
  • &$group: Group object

Example

edit

Add this to LocalSettings.php to add a link to the file upload page at the bottom of the contribution tools section of the mobile menu:

// adds upload menu item with upload icon to discovery menu.
$wgHooks['MobileMenu'][] = function ( $name, \MediaWiki\Minerva\Menu\Group &$group ) {
    if ( $name !== 'discovery' ) {
            $group->insert( 'upload' )
			->addComponent(
                    'mobile-frontend-upload-button',
                    SpecialPage::getTitleFor( 'Upload' )->getLocalUrl() . '#/upload',
                    MobileUI::iconClass( 'mf-upload-invert', 'before' ),
	                [
                        'id' => 'uploadButton',
                        'data-event-name' => 'upload',
                    ]   
			);
	}
};