Extension:GoogleSiteSearch
From Linux Web Expert
GoogleSiteSearch Release status: stable |
|
---|---|
Implementation | Search |
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+ |
PHP | 7.0+ |
License | GNU General Public License 2.0 or later |
Download | |
Example | appropedia.org search result |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
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
. - <translate> [[<tvar name=2>Special:ExtensionDistributor/GoogleSiteSearch</tvar>|Download]] and move the extracted <tvar name=name>
GoogleSiteSearch
</tvar> folder to your <tvar name=ext>extensions/
</tvar> directory.</translate>
<translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/GoogleSiteSearch - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'GoogleSiteSearch' ); $wgGoogleSiteSearchCSEID = 'YOUR_CSE_ID';
- Configure as required.
- File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
Configuration
The following configuration parameters are available:
$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. Optional, defaults tofalse
. $wgGoogleSiteSearchAppend
- Whether to prepend (not append) rather than replace the Google search results. Defaults to
false
. 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. $wgGoogleSiteSearchAttributes
- An array of optional Custom Search element attributes. For example, to make links open in a new window/tab:
$wgGoogleSiteSearchAttributes = [ 'linkTarget' => '_blank' ];
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.
Categories:
- Pages with script errors
- Pages with broken file links
- Stable extensions
- Extensions without an image
- Search extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- GPL licensed extensions
- Extensions in Wikimedia version control
- SpecialSearchResultsAppend extensions
- SpecialSearchResultsPrepend extensions
- All extensions
- Google extensions