Jump to content

Manual:Hooks/SpecialSearchGoResult

From mediawiki.org
SpecialSearchGoResult
Available from version 1.27.0
Called before the 'go' feature of SpecialSearch redirects a user. May provide it's own url to redirect to.
Define function:
public static function onSpecialSearchGoResult( $term, Title $title, &$url ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"SpecialSearchGoResult": "MediaWiki\\Extension\\MyExtension\\Hooks::onSpecialSearchGoResult"
	}
}
Called from: File(s): SpecialSearch.php
Interface: SpecialSearchGoResultHook.php

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


Description

[edit]

If a hook returns false the 'go' feature will be canceled and a normal search will be performed. Returning true without setting $url does a standard redirect to $title. Setting $url redirects to the specified URL.

Details

[edit]

$term - The string the user searched for

$title - The title the 'go' feature has decided to forward the user to

&$url - Initially null, hook subscribers can set this to specify the final url to redirect to