Manual:Hooks/ApiOpenSearchSuggest

From MediaWiki.org
Jump to navigation Jump to search
ApiOpenSearchSuggest
Available from version 1.25.0
Called when constructing the OpenSearch results. Hooks can alter or append to the array.
Define function:
public static function onApiOpenSearchSuggest( &$results ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"ApiOpenSearchSuggest": "MyExtensionHooks::onApiOpenSearchSuggest"
	}
}

For MediaWiki ≤1.25:

$wgHooks['ApiOpenSearchSuggest'][] = 'MyExtensionHooks::onApiOpenSearchSuggest';
Called from:File(s): ApiOpenSearch.php

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

Details[edit]

  • &$results: array with integer keys to associative arrays. Keys in associative:
    • title: Title object.
    • redirect from: Title or null.
    • extract: Description for this result.
    • extract trimmed: If truthy, the extract will not be trimmed to $wgOpenSearchDescriptionLength.
    • image: Thumbnail for this result. Value is an array with subkeys 'source' (url), 'width', 'height', 'alt', 'align'.
    • url: Url for the given title.