Extension:GoogleSiteSearch
![]() Release status: stableCategory:Stable extensions |
|
---|---|
Implementation | SearchCategory:Search extensions |
Description | Prepends to, or replaces, Special:Search results with Google CSE results |
Author(s) | Ryan Finnie (Fo0bartalk) |
Maintainer(s) | Sophivorus |
Latest version | 3.1 (2022-09-23) |
MediaWiki | 1.32+Category:Extensions with manual MediaWiki version |
PHP | 7.0+ |
License | GNU General Public License 2.0 or later |
Download | Category:Extensions in Wikimedia version control |
Example | appropedia.org search result |
|
|
Quarterly downloads | 3 (Ranked 84th) |
Translate the GoogleSiteSearch extension if it is available at translatewiki.net |
The GoogleSiteSearch extension allows you to prepend Google Custom Search Engine (CSE) results to "Special:Search" additionally to MediaWiki search results, or optionally, replace them altogether.
Installation
- Go to the Google CSE management page and add a custom search engine. Note down the "Search engine unique ID". It should be in the format
numbers:letters
. - Download and move the extracted
GoogleSiteSearch
folder to yourextensions/
directory.
Developers and code contributors should install the extension from Git instead, using:cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleSiteSearch - Add the following code at the bottom of your LocalSettings.php file:
wfLoadExtension( 'GoogleSiteSearch' ); $wgGoogleSiteSearchCSEID = 'YOUR_CSE_ID';
- Configure as required.
Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.
Configuration
The following configuration parameters are available:
Name | Description | Default | Required? |
---|---|---|---|
$wgGoogleSiteSearchCSEID | The ID of the created Google custom search engine. | Required | |
$wgGoogleSiteSearchOnly |
Whether to replace the the MediaWiki search results. If true , only the CSE search results are shown. If false, the CSE results are shown above the MediaWiki results. |
false |
Optional |
$wgGoogleSiteSearchAppend |
Whether to prepend (not append) rather than replace the Google search results. Note that under some circumstances, for example when they're too many or no search results, the relevant hook may not fire and Google search results will not be appended. | false |
Optional |
$wgGoogleSiteSearchAttributes |
An array of optional Custom Search element attributes. For example, to make links open in a new window/tab: $wgGoogleSiteSearchAttributes = [
'linkTarget' => '_blank'
];
|
Optional |
In addition, the HTML built by the extension is customizable via the "GoogleSiteSearchHTML" hook. For example:
$wgHooks['GoogleSiteSearchHTML'][] = function ( $specialSearch, $term, &$html ) {
$html .= '<p>Example append</p>';
};
See also
- Extension:GoogleCustomWikiSearch - Offers similar functionality but appends search after, rather than before MediaWiki search if set to add to, rather than replace, search.
Category:All extensions
Category:Extensions in Wikimedia version control
Category:Extensions with manual MediaWiki version
Category:Extensions without a compatibility policy
Category:Extensions without an image
Category:GPL licensed extensions
Category:Google extensions
Category:Search extensions
Category:SpecialSearchResultsAppend extensions
Category:SpecialSearchResultsPrepend extensions
Category:Stable extensions