This page is semi-protected against editing.

Template:Search box

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search
Template documentationview · edit · history · purge ]
This documentation is transcluded from Template:Search box/doc.

This template may be used to add an input box to let the user search a set of pages, for example archived Talk pages.

Usage

{{search box
 |root =
 |search-break =
 |search-width =
 |search-button-label =
}}

Template parameters

ParameterDescriptionDefaultStatus
rootroot pagePrefix to search pages starting with. For example, if its value is “User talk:Example/Archives”, the template will search in pages starting with User talk:Example/Archives.{{FULLPAGENAME}}optional
nosuffixomit slash suffixIf this parameter is present (either with any value or as blank), there will be no slash appended to the root page title.emptyoptional
search-breakline breakWhether to insert a line break between the search field and the button; “yes” or “no”.nooptional
search-widthwidthWidth of the search field in characters (bare number without any unit)22optional
search-button-labelbutton labelThe text of the search buttonSearchoptional
Template data
<templatedata>JSON</templatedata> ./. {{TemplateBox}}
TemplateData

TemplateData is a way to store information about template parameters (the description of those and of the whole template) for both humans and machines. It is used by VisualEditor and possibly other tools like Upload Wizard.


Existing template documentation
At Wikimedia Commons, it is recommended to use {{TemplateBox}} with either ‎useTemplateData=1 or ‎useTemplateData=only on the ‎/doc subpage and transcluding it with {{Documentation}} into the template. ‎<nowiki>-tags can be wrapped around the arguments, if required, to avoid templates being expanded.

Newly created template documentation and imports
Another option, especially for imported templates, or for users with JSON experience, is placing raw ‎<templatedata>-tags into the Wikitext of the template, as described in various Wikipediae.

Discussion
There is an ongoing discussion about that matter. Feel invited to comment if you are experienced in either way, your time permits and if you like to share your opinion or to make a suggestion.


Wikipedia's help about TemplateDataCommons-specific information

This template may be used to add an input box to let the user search a set of pages, for example archived Talk pages.

[Edit template data]

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
omit slash suffixnosuffix

If this parameter is present (either with any value or as blank), there will be no slash appended to the root page title.

Lineoptional
root pageroot

Prefix to search pages starting with. For example, if its value is “User talk:Example/Archives”, the template will search in pages starting with User talk:Example/Archives.

Default
{{FULLPAGENAME}}
Page nameoptional
line breaksearch-break

Whether to insert a line break between the search field and the button; “yes” or “no”.

Default
no
Lineoptional
button labelsearch-button-label

The text of the search button

Default
Search
Lineoptional
widthsearch-width

Width of the search field in characters (bare number without any unit)

Default
22
Numberoptional

Additional information

The template is intended to be used in the following namespaces: all talk namespaces and noticeboards

The template is intended to be used by the following user groups: all users

Placement: At the top of the page

See also

Examples

{{search box
 |root= User:84user
 |search-break=no
 |search-width=22
 |search-button-label=Search User:84user with suffix
}}

produces


{{search box
 |root= User:84user
 |nosuffix
 |search-break=no
 |search-width=22
 |search-button-label=Search User:84user with nosuffix ignored
}}

produces


{{search box
 |root= User:84user
 |search-break=no
 |search-width=22
 |search-button-label=Search User:84user with suffix
}}

produces


{{search box
 |root= User:84user
 |nosuffix=
 |search-break=no
 |search-width=22
 |search-button-label=Search User:84user with no suffix
}}

produces


{{search box
 |root= User:84user
 |nosuffix=anything
 |search-break=no
 |search-width=22
 |search-button-label=Search User:84user with no suffix=anything
}}

produces


Wrap the template call in a table to workaround the formatting (see source for details):
https://commons.wikimedia.org/wiki/Template:Search_box
commons.wikimedia.org
CC-MAIN-2023-14
59245
application/http; msgtype=response
sha1:ZYQ7PXLYDWXAODB7EGOX7NXDW5CMJQOT
<urn:uuid:61c0b2ef-f010-4327-a312-26235650b9d9>
2023-03-25T06:01:19Z
208.80.154.224
text/html
sha1:AE25WIMXF4KLR74Z4ULMXWZR4MFXRO4W
<urn:uuid:0e1eeee2-50cf-4fba-b2e1-cac0e445c36e>
https://commons.wikimedia.org/wiki/Template:Search_box
response
<urn:uuid:666dab6f-3723-4df8-bca1-d90f1453560c>
isPartOf: CC-MAIN-2023-14
publisher: Common Crawl
description: Wide crawl of the web for March/April 2023
operator: Common Crawl Admin (info@commoncrawl.org)
hostname: ip-10-67-67-159
software: Apache Nutch 1.19 (modified, https://github.com/commoncrawl/nutch/)
robots: checked via crawler-commons 1.4-SNAPSHOT (https://github.com/crawler-commons/crawler-commons)
format: WARC File Format 1.1
conformsTo: https://iipc.github.io/warc-specifications/specifications/warc-format/warc-1.1/