Template:Find sources multi/doc
This is a documentation subpage for Template:Find sources multi. It may contain usage information, categories and other content that is not part of the original template page. |
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.
Usage
Search values
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).
Search engine links
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
. See #Link codes for the full list.
Simple usage
For example, the code:
{{find sources multi|Example|link1=g|link2=gbooks}}
Will produce:
Usage in templates
>
{{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
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:'' |
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 - 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 |
- |
no | Unlinked text displayed between the intro link and the first link. If spaces are desired they must be specified with - 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.
|
separator |
, |
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 - 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 - 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}}. |
Link codes
Here is a list of currently supported values for the link parameters (up to 20 may be specified):
Code | Aliases | Preview | Search engine description | Subtemplate | Notes |
---|---|---|---|---|---|
g |
google |
Google, the flagship search engine from Google Inc. | Template:Find sources multi/g | ||
gnews |
gn |
Google News | Google News, Google's search engine for news sites. | Template:Find sources multi/gnews | Can be used with |free=yes to return free results only. Google News search does not work as of December 2013. |
gbooks |
gb |
Google Books | Google Books, Google's search engine for books. | Template:Find sources multi/gbooks | |
gscholar |
gs |
Google Scholar | Google Scholar, Google's search engine for academic papers and other scholarly research. | Template:Find sources multi/gscholar | |
jstor |
|
JSTOR | JSTOR, an online library containing digitised versions of academic journals. Requires a subscription. | Template:Find sources multi/jstor | |
gfreeimages |
gfi |
Free Google Images | Google Images, Google's search engine for images. Only images compatible with Wikipedia's licensing are included. | Template:Find sources multi/gfreeimages | |
archive |
ia |
Archive.org | The Internet Archive, a digital library of public websites. | Template:Find sources multi/archive | |
bing |
msbooks, msacademic |
Bing | Bing, Microsoft's flagship search engine. | Template:Find sources multi/bing | This is a replacement for MS Books and MS Academic, which unfortunately have been discontinued by Microsoft. |
gnewsrecent |
gnr |
Google News recent | Google News, Google's search engine for news sites. Only recent news stories will be searched for. | Template:Find sources multi/gnewsrecent | |
nyt |
nytrecent, nytold |
New York Times | The website of The New York Times, a highly respected newspaper. | Template:Find sources multi/nyt | This is a replacement for the NYT Recent and NYT Old searches; these two searches have now been combined into one search interface on the NYT website. |
ddg |
|
DuckDuckGo | DuckDuckGo, a search engine that uses information from crowd-sourced websites (such as Wikipedia) to provide its results. | Template:Find sources multi/ddg | |
gnewspapers |
gnewspaper, gnp |
Google Newspapers | Google Newspapers, a search of Google's digital archive of print newspapers. | Template:Find sources multi/gnewspapers |
Examples
Without documentation or self-checks
- Code
Template code
|
---|
{{find sources multi
|1 = {{{1|}}}
|2 = {{{2|}}}
|3 = {{{3|}}}
|4 = {{{4|}}}
|5 = {{{5|}}}
|introtext = Find sources:&nbsp;
|introlink = g
|introseparator = &nbsp;-&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
- Code
Template code
|
---|
{{find sources multi<noinclude>/template</noinclude>
|1 = {{{1|}}}
|2 = {{{2|}}}
|3 = {{{3|}}}
|4 = {{{4|}}}
|5 = {{{5|}}}
|introtext = Find sources:&nbsp;
|introlink = g
|introseparator = &nbsp;-&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
This is the {{Find sources multi}} source search template. It uses the Template:Find sources multi meta-template. |
With self-checks and documentation
(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:&nbsp;
|introlink = g
|introseparator = &nbsp;-&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
This is the {{Find sources multi}} source search template. It uses the Template:Find sources multi meta-template. |
Smallcaps style
- 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:&nbsp;
|introlink = g
|introseparator = &nbsp;-&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
- Code
Template code
|
---|
{{find sources multi
|1 = {{{1|}}}
|2 = {{{2|}}}
|3 = {{{3|}}}
|4 = {{{4|}}}
|5 = {{{5|}}}
|introtext = Find sources:&nbsp;
|introlink = g
|introseparator = &nbsp;-&nbsp;
|separator = ,&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
Bulleted list
- Code
Template code
|
---|
{{find sources multi
|1 = {{{1|}}}
|2 = {{{2|}}}
|3 = {{{3|}}}
|4 = {{{4|}}}
|5 = {{{5|}}}
|introtext = Find sources for&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|}}}
}} |
Adding new search subtemplates
To add a new search subtemplate, please follow these steps:
- Create the subtemplate.
- Subtemplate names should be kept short.
- The subtemplate should have five unnamed parameters and one
|display=
parameter. - You can use {{find sources multi/g}} as a base for your code.
- The documentation should be transcluded from Template:Find sources multi/doc/links.
- Add the data about your subtemplate to {{find sources multi/linkinfo}}.
- 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. - 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
- Category:Source-finding templates
- Category:Find sources multi transclusions with errors
- Help:Find sources