Jump to content

Template:Find sources multi/doc

From Wikipedia, the free encyclopedia

This is a meta-template for "find sources" templates. It is usually called from another template, but can be used on its own as well. It produces a series of links to various search interfaces to help find additional sources for articles. Using this meta-template has the advantage that if a search engine changes its parameters, it is only necessary to fix this one template rather than individual fixes to all the different source-finding templates. The syntax is also very flexible, allowing for a wide range of styles of daughter template, and it is possible to create new subtemplates to add additional search engines without altering the main template code.

This template, and other templates that are based on it, should not usually be used in articles themselves - see Wikipedia:EL#Links normally to be avoided.

Usage

[edit]

Search values

[edit]

No matter what invocation is used, the searching works in the same way. The first parameter is main search term, which will be treated as a literal string if multi-part (e.g. Albert Einstein will be searched as the single string "Albert Einstein" not "Albert" and "Einstein" separately).

Optional subsequent parameters (up to 4) are additional search terms. They can be enclosed in double quotation marks, preceded by an unspaced - (hyphen) to exclude them from the search results, or both (e.g. -"Marilyn Monroe" to exclude matches containing the phrase "Marilyn Monroe", but not either name by itself, from the search results). You do not need to add -wikipedia, as the template automatically does this for you. Also, there is usually no need to add words in plural form unless irregular, as most search interfaces will match (for example) billiards as well given a search term of billiard.

If no parameters are given, the name of the article is passed as the search string. Note that this may or may not be desirable with disambiguated article names (if the Wikipedia disambiguator is sensible, however, it may actually help refine the search results).

[edit]

Search engine links are provided by the parameters link1, link2, link3 ... link20. These parameters may take the values g, gbooks, gscholar, jstor, gfreeimages, archive, bing, gnewsrecent, nyt, wrs, or ddg. The code gnews is also available, but it is not working as of December 2013. See #Link codes for the full list.

Simple usage

[edit]

{{find sources multi}}

For example, the code:

{{find sources multi|Example|link1=g|link2=gbooks}}

Will produce:

Google · Google Books

Usage in templates

[edit]
>
{{find sources multi<noinclude>/template</noinclude>
|class          = <!-- sets the span class -->
|style          = <!-- custom css style -->
|inarticle      = <!-- set to "yes" if the template is to be used in articles -->

|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}

|introtext      = <!-- unlinked text that appears at the start of the template output -->
|introlink      = <!-- search engine link code for a link after the intro text but before the other links -->
|introdisplay   = <!-- text displayed for the intro link; the default value is the term searched for -->
|introseparator = <!-- unlinked text that appears after the intro link and before the other links -->

<!-- |separator =      custom separator value; if this is not used, the whole parameter should be removed -->

|link1          = <!-- search engine code for the first link -->
|display1       = <!-- display value for the first link -->
|link2          = <!-- search engine code for the second link -->
|display2       = <!-- display value for the second link -->
<!-- ... -->
|link20         = 
|display20      = 

|free           = {{{free|}}}

|endseparator   = <!-- unlinked text that appears after the last link but before the closing span tag -->

<noinclude>
|doc            = <!-- set to "yes" to use the automatically generated documentation -->
</noinclude>
}}

To create a template based on find sources multi, copy the code above and experiment with the parameters until it looks how you want it to. Make sure that you keep the top line as it is - the code on the top line allows the template to use {{find sources multi/template}} on the template page, but {{find sources multi}} everywhere else.

{{Find sources multi/template}} has a few special features that distinguish it from the main {{find sources multi}} template. First, it sets the search text in any links used to "Example", rather than the default of the current subpage. Second, it allows automatic checking of the link codes used in the template. If any of the codes do not exist, the template will generate an error message. Third, it can generate documentation for the template automatically. If you want to use the automatic documentation, set |doc=yes - the documentation itself is generated by {{find sources multi/doc/template}}.

If you want to add a shortcut to your template, you can specify it at {{find sources multi/doc/template}}, and any additional categories or instructions can be added to the /doc subpage as normal. If further customisation is desired, the template can be substituted - see here for instructions.

Parameters

[edit]
Parameter name Example values Required Description
class smallcaps no Custom class values. The template already uses the "plainlinks" class by default; any other classes will be used in addition to this.
style font-variant: small-caps; no Custom CSS styles. The template doesn't use any default styles.
unnamed parameter 1 {{{1|}}} no The first search term. This will be placed inside quotation marks in the search. If this parameter is left out, the name of the current subpage is used instead.
unnamed parameters 2-5 {{{2|}}}, {{{3|}}}, etc. no The other search terms. These will included in the search without quotation marks.
introtext ''Find sources:''&nbsp; no Unlinked text that appears at the start of the template output. If a space is desired at the end of this text it must be specified with &nbsp; - other whitespace will be trimmed off.
introlink gbooks no The search engine link code for the intro link. This link comes after the intro text but before the other links.
introdisplay Google no The text displayed for the intro link. The default value is the term searched for.
introseparator &nbsp;-&nbsp; no Unlinked text displayed between the intro link and the first link. If spaces are desired they must be specified with &nbsp; - other whitespace will be trimmed off.
link1 gbooks yes The search engine link code for the first link.
link2, link3 ... link20 gscholar no The search engine link codes for the other links. Up to 20 links (plus the intro link) are allowed.
display1, display3 ... display20 Books no The text displayed for the links. These default to descriptive values such as "Google Books", "Archive.org", etc. The default display values are set by the individual subtemplates - see #Link codes for the full list.
free {{{free|}}} no If |free=yes then only free (as in beer) results are returned for Google News. If your template uses a Google News search then you should probably pass this parameter through so that end users can set it as desired. If your template doesn't use Google News then you can leave this parameter out. Note: Google News search does not work as of December 2013.
separator ,&nbsp; no This specifies a custom search link separator. It is unlinked text that goes between the links generated by the linkX parameters. If whitespace is desired it must be specified with &nbsp; - other whitespace will be trimmed off. The default value is {{int:dot-separator}} (displays as  · ). If this parameter is not used, the parameter name must be completely removed from the template, otherwise an error message is generated. (This is due to limitations in MediaWiki's whitespace handling for templates.)
endseparator . no Unlinked text displayed after the last search link. If spaces are desired they must be specified with &nbsp; - other whitespace will be trimmed off.
inarticle yes no If the template is designed to be used in articles, set this to "yes". If this parameter is not set and the template is used in the main namespace, it will generate an error message.
doc yes no This is used only on template pages themselves, through {{find sources multi/template}}. If |doc=yes, the template will generate documentation for your template automatically.
demo yes no This suppresses Category:Source-finding templates for examples that use {{find sources multi/template}}.
[edit]

Here is a list of currently supported values for the link parameters (up to 20 may be specified):

Examples

[edit]

Without documentation or self-checks

[edit]
Code
Template code
{{find sources multi
|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}
|introtext      = Find sources:&amp;nbsp;
|introlink      = g
|introseparator = &amp;nbsp;-&amp;nbsp;
|link1          = gbooks
|display1       = books
|link2          = gscholar
|display2       = scholar
|link3          = jstor
|display3       = JSTOR
|link4         = gfreeimages
|display4       = free images
|free           = {{{free|}}}
}}
Output

Find sources: "doc" - books · scholar · JSTOR · free images

With self-checks but no documentation

[edit]
Code
Template code
{{find sources multi<noinclude>/template</noinclude>
|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}
|introtext      = Find sources:&amp;nbsp;
|introlink      = g
|introseparator = &amp;nbsp;-&amp;nbsp;
|link1          = gbooks
|display1       = books
|link2          = gscholar
|display2       = scholar
|link3          = jstor
|display3       = JSTOR
|link4          = gfreeimages
|display4       = free images
|free           = {{{free|}}}
}}
Output

Find sources: "Example" - books · scholar · JSTOR · free images

With self-checks and documentation

[edit]

(You need to visit the /doc subpage to see this working properly.)

Code
Template code
{{find sources multi<noinclude>/template</noinclude>
|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}
|introtext      = Find sources:&amp;nbsp;
|introlink      = g
|introseparator = &amp;nbsp;-&amp;nbsp;
|link1          = gbooks
|display1       = books
|link2          = gscholar
|display2       = scholar
|link3          = jstor
|display3       = JSTOR
|link4          = gfreeimages
|display4       = free images
|free           = {{{free|}}}
<noinclude>
|doc            = yes
</noinclude>
}}
Output

Find sources: "Example" - books · scholar · JSTOR · free images

Smallcaps style

[edit]
Code
Template code
{{find sources multi
|class          = smallcaps
|style          = font-variant: small-caps;
|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}
|introtext      = Find sources:&amp;nbsp;
|introlink      = g
|introseparator = &amp;nbsp;-&amp;nbsp;
|link1          = gbooks
|display1       = books
|link2          = gscholar
|display2       = scholar
|link3          = jstor
|display3       = jstor
|link4          = gfreeimages
|display4       = free images
|free           = {{{free|}}}
}}
Output

Find sources: "doc" - books · scholar · jstor · free images

Custom separator

[edit]
Code
Template code
{{find sources multi
|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}
|introtext      = Find sources:&amp;nbsp;
|introlink      = g
|introseparator = &amp;nbsp;-&amp;nbsp;
|separator      = ,&amp;nbsp;
|link1          = gbooks
|display1       = books
|link2          = gscholar
|display2       = scholar
|link3          = jstor
|display3       = jstor
|link4          = gfreeimages
|display4      = free images
|free           = {{{free|}}}
}}
Output

Find sources: "doc" - booksscholarjstorfree images

Bulleted list

[edit]
Code
Template code
{{find sources multi
|1              = {{{1|}}}
|2              = {{{2|}}}
|3              = {{{3|}}}
|4              = {{{4|}}}
|5              = {{{5|}}}
|introtext      = Find sources for&amp;nbsp;
|introlink      = g
|introseparator = :<ul><li>
|separator      = </li><li>
|link1         = gbooks
|display1       = books
|link2          = gscholar
|display2       = scholar
|link3          = jstor
|display3       = jstor
|link4          = gfreeimages
|display4       = free images
|endseparator   = </li></ul>
|free           = {{{free|}}}
}}
Find sources for "doc":

Adding new search subtemplates

[edit]

To add a new search subtemplate, please follow these steps:

  1. Create the subtemplate.
  2. Add the data about your subtemplate to {{find sources multi/linkinfo}}.
  3. Create redirects for any aliases you specified in {{find sources multi/linkinfo}}. The pages of the form Template:Find sources multi/aliasname must redirect to your subtemplate.
  4. Create any template shortcuts that you specified in {{find sources multi/linkinfo}}.

You can now use your new subtemplate directly from {{find sources multi}}.

See also

[edit]