Jump to content

Template:Search

From mediawiki.org
Template documentation

Use this template to search the wiki and display the results in a wiki page.

See the installation instructions to get it working in your wiki.

Usage

[edit]

Basic

[edit]
Markup Renders as
{{Search|javascript}}
Searching...

Advanced

[edit]
Markup Renders as
{{Search
| query = incategory:JavaScript
| namespace = 2
| limit = 100
| sort = incoming_links_desc
}}
Searching...

Installation

[edit]

To install this template in your wiki:

  1. Create a template with the following markup. You can choose the template name, parameter names and defaults to suit your wiki.
    <includeonly><div class="InlineSearch"
    data-search="{{{1|{{{query|}}}}}}"
    data-namespace="{{{namespace|}}}"
    data-limit="{{{limit|}}}"
    data-sort="{{{sort|}}}"
    >Searching...</div>[[Category:Gadget:InlineSearch]]</includeonly>
    
  2. Create MediaWiki:Gadget-InlineSearch.js with the following code:
    /**
     * InlineSearch allows to search the wiki and display the results in a wiki page
     * Documentation: https://www.mediawiki.org/wiki/InlineSearch
     * Source code: https://www.mediawiki.org/wiki/MediaWiki:Gadget-Global-InlineSearch.js
     */
    mw.loader.load( '//www.mediawiki.org/w/load.php?modules=ext.gadget.Global-InlineSearch' );
    
  3. Add the following gadget to MediaWiki:Gadgets-definition:
    * InlineSearch[ResourceLoader|hidden|default|categories=Gadget:InlineSearch]|InlineSearch.js
    

Done! Add your template to any page to verify that the installation was successful.

Template data

[edit]

Use this template to search the wiki and display the results inline

Template parameters[Edit template data]

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Queryquery 1

Search terms or query

Stringrequired
Namespacenamespace

Namespace number to search

Example
2
Numberoptional
Limitlimit

Max search results to show

Default
10
Example
100
Numberoptional
Sortsort

Sort criteria for search results

Suggested values
create_timestamp_asc create_timestamp_desc incoming_links_asc incoming_links_desc last_edit_asc last_edit_desc random relevance
Default
relevance
Example
create_timestamp_asc
Stringoptional

See also

[edit]