Manual:Hooks/LanguageLinks

Category:MediaWiki hooks#LanguageLinks Category:Hooks added in MediaWiki 1.22.0#LanguageLinks
LanguageLinks
Available from version 1.22.0
Manipulate a page's language links.

This is called in various places to allow extensions to define the effective language links for a page.

Define function:
public static function onLanguageLinks( $title, &$links, &$linkFlags ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"LanguageLinks": "MediaWiki\\Extension\\MyExtension\\Hooks::onLanguageLinks"
	}
}
Called from: File(s): api/ApiParse.phpCategory:MediaWiki hooks included in ApiParse.php#LanguageLinks, OutputPage.phpCategory:MediaWiki hooks included in OutputPage.php#LanguageLinks
Interface: LanguageLinksHook.php

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

Example

$wgHooks['LanguageLinks'][] = function ( $title, &$links, &$linkFlags ) {
        // add Esperanto easter egg to all egg-related topics
        if ( stripos( $title->getText(), 'egg' ) !== false ) {
            $links[] = 'eo:Paska_ovo';
        }
        return true;
};
Category:Hooks added in MediaWiki 1.22.0 Category:MediaWiki hooks Category:MediaWiki hooks included in ApiParse.php Category:MediaWiki hooks included in OutputPage.php