Manual:Hooks/SpecialSearchGoResult

From Linux Web Expert

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

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:SpecialSearchGoResult extensions</tvar>.</translate>


Description

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

$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