Jump to content

Manual:Hooks/GetLocalURL

From mediawiki.org
GetLocalURL
Available from version 1.6.0
Used to modify local URLs as output into page links
Define function:
public static function onGetLocalURL( $title, $url, $query ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"GetLocalURL": "MediaWiki\\Extension\\MyExtension\\Hooks::onGetLocalURL"
	}
}
Called from: File(s): Title.php
Interface: GetLocalURLHook.php

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

Details

[edit]
  • $title: Title object of page
  • $url: string value as output (out parameter, can modify)
  • $query: query options passed to Title::getLocalURL()

Usage

[edit]

This hook can be used to alter the canonical URL of pages under specific circumstances. This is useful for instance since git #155d555b (MediaWiki 1.26) made MediaWiki automatically redirect from non-standard to canonical URLs. See an example usage at git #92dd60c4