Manual:Hooks/SpecialSearchProfiles
Appearance
SpecialSearchProfiles | |
---|---|
Available from version 1.16.0 Allows modification of search profiles. | |
Define function: | public static function onSpecialSearchProfiles( &$profiles ) { ... }
|
Attach hook: | In extension.json:
{
"Hooks": {
"SpecialSearchProfiles": "MediaWiki\\Extension\\MyExtension\\Hooks::onSpecialSearchProfiles"
}
}
|
Called from: | File(s): specials/SpecialSearch.php |
Interface: | SpecialSearchProfilesHook.php |
For more information about attaching hooks, see Manual:Hooks .
For examples of extensions using this hook, see Category:SpecialSearchProfiles extensions.
Details
[edit]Parameters:
&$profiles
: profiles, which can be modified.
The array $profiles
is a dictionary whose the keys are the profile names and the values are dictionaries with the following keys:
'message'
: MediaWiki message name for the label,'tooltip'
: MediaWiki message name for the tooltip, it may contain an argument $1 if the key'namespace-messages'
is provided,'namespaces'
: list of namespace IDs,'namespace-messages'
: (optional) list of strings where each string is a namespace name (e.g. "File"), this list will be joined by commas and injected as the argument $1 in the tooltip,'parameters'
: (internal) parameters to be put in the URL when the user selects the profile.
The default value of $profiles
since MediaWiki 1.24 is:
$profiles = [
'default' => [
'message' => 'searchprofile-articles',
'tooltip' => 'searchprofile-articles-tooltip',
'namespaces' => $defaultNs,
'namespace-messages' => $this->searchConfig->namespacesAsText(
$defaultNs
),
],
'images' => [
'message' => 'searchprofile-images',
'tooltip' => 'searchprofile-images-tooltip',
'namespaces' => [ NS_FILE ],
],
'all' => [
'message' => 'searchprofile-everything',
'tooltip' => 'searchprofile-everything-tooltip',
'namespaces' => $nsAllSet,
],
'advanced' => [
'message' => 'searchprofile-advanced',
'tooltip' => 'searchprofile-advanced-tooltip',
'namespaces' => 'sense',
]
];
where:
$nsAllSet
is all searchable namespaces (all namespaces whose ID is >= 0 but possible restricted by the hook SearchableNamespaces),$defaultNs
is given by$wgNamespacesToBeSearchedDefault
,- the profile named
'advanced'
is specially recognised and let the user select a specific list of namespaces.