Jump to content

Extension:CustomSearchProfiles

From mediawiki.org
MediaWiki extensions manual
CustomSearchProfiles
Release status: experimental
Implementation Special page
Description This extension adds extra search profiles on Special:Search
Author(s) Claire (BlankEclairtalk)
Compatibility policy Main branch maintains backward compatibility.
MediaWiki >= 1.35.0
Database changes No
License GNU General Public License 2.0 or later
Download
Example https://rainverse.wiki/wiki/Special:Search
  • $wgCustomSearchProfilesProfiles

The CustomSearchProfiles extension allows you to add custom search profiles into Special:Search. All extra search profiles are added before the "Everything" profile.

Installation

[edit]
  • Clone the repository and place the file(s) in a directory called CustomSearchProfiles in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php file:
    wfLoadExtension( 'CustomSearchProfiles' );
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Configuration parameters

[edit]
  • $wgCustomSearchProfilesProfiles (array): List of custom search profiles. Its keys are the profile's internal ID, and its values are objects. They are represented as follows:
    • message (string, optional): Localisation string used to display the profile in Special:Search. Defaults to searchprofile-${key}.
    • tooltip (string, optional): Localisation string used when the profile is hovered over in Special:Search. Defaults to searchprofile-${key}-tooltip.
    • namespaces (array of ints): Namespaces that this profile will search

Example

[edit]
$wgCustomSearchProfilesProfiles = [
    'code' => [
        'namespaces' => [
            NS_TEMPLATE,
            828, // Module
        ],
    ],
    'mediawiki' => [
        'message' => 'searchprofile-sysmsgs',
        'tooltip' => 'searchprofile-sysmsgs-tooltip',
        'namespaces' => [ NS_MEDIAWIKI ],
    ],
];