Difference between revisions of "Template:Find sources multi/linkinfo"

From blackwiki
Jump to navigation Jump to search
imported>Mr. Stradivarius
(Add documentation)
imported>Mr. Stradivarius
(Change to remove default values - this will make the template less likely to fail when updated)
Line 2: Line 2:
  
 
  | <!-- linkn --> | <!-- ln --> | <!-- code --> = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | <!-- linkn --> | <!-- ln --> | <!-- code --> = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = <!-- the main link code; this must be the exact subpage name of the link template -->
+
     | code           = <!-- the main link code; this must be the exact subpage name of the link template -->
 
     | alias1          = <!-- alias1 to alias4 are aliases for the main link code -->
 
     | alias1          = <!-- alias1 to alias4 are aliases for the main link code -->
 
     | alias2          =  
 
     | alias2          =  
Line 16: Line 16:
  
 
  | link1 | l1 | g = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link1 | l1 | g = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = g
+
     | code           = g
 
     | alias1          = google
 
     | alias1          = google
 
     | alias2          =  
 
     | alias2          =  
Line 30: Line 30:
  
 
  | link2 | l2 | gnews = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link2 | l2 | gnews = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = gnews
+
     | code           = gnews
 
     | alias1          = gn
 
     | alias1          = gn
 
     | alias2          =  
 
     | alias2          =  
Line 44: Line 44:
  
 
  | link3 | l3 | gbooks = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link3 | l3 | gbooks = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = gbooks
+
     | code           = gbooks
 
     | alias1          = gb
 
     | alias1          = gb
 
     | alias2          =  
 
     | alias2          =  
Line 58: Line 58:
  
 
  | link4 | l4 | gscholar = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link4 | l4 | gscholar = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = gscholar
+
     | code           = gscholar
 
     | alias1          = gs
 
     | alias1          = gs
 
     | alias2          =  
 
     | alias2          =  
Line 73: Line 73:
  
 
  | link5 | l5 | jstor = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link5 | l5 | jstor = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = jstor
+
     | code           = jstor
 
     | alias1          =  
 
     | alias1          =  
 
     | alias2          =  
 
     | alias2          =  
Line 87: Line 87:
  
 
  | link6 | l6 | gfreeimages = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link6 | l6 | gfreeimages = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = gfreeimages
+
     | code           = gfreeimages
 
     | alias1          = gfi
 
     | alias1          = gfi
 
     | alias2          =  
 
     | alias2          =  
Line 101: Line 101:
  
 
  | link7 | l7 | archive = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link7 | l7 | archive = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = archive
+
     | code           = archive
 
     | alias1          = ia
 
     | alias1          = ia
 
     | alias2          =  
 
     | alias2          =  
Line 115: Line 115:
  
 
  | link8 | l8 | bing = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link8 | l8 | bing = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = bing
+
     | code           = bing
 
     | alias1          = msbooks
 
     | alias1          = msbooks
 
     | alias2          = msacademic
 
     | alias2          = msacademic
Line 129: Line 129:
  
 
  | link9 | l9 | gnewsrecent = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link9 | l9 | gnewsrecent = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = gnewsrecent
+
     | code           = gnewsrecent
 
     | alias1          = gnr
 
     | alias1          = gnr
 
     | alias2          =  
 
     | alias2          =  
Line 143: Line 143:
  
 
  | link10 | l10 | nyt = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link10 | l10 | nyt = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = nyt
+
     | code           = nyt
 
     | alias1          = nytrecent
 
     | alias1          = nytrecent
 
     | alias2          = nytold
 
     | alias2          = nytold
Line 157: Line 157:
  
 
  | link11 | l11 | wrs = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link11 | l11 | wrs = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = wrs
+
     | code           = wrs
 
     | alias1          =  
 
     | alias1          =  
 
     | alias2          =  
 
     | alias2          =  
Line 171: Line 171:
  
 
  | link12 | l12 | ddg = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
 
  | link12 | l12 | ddg = {{<includeonly>safesubst:</includeonly>#switch: {{{2}}}
     | code | #default = ddg
+
     | code           = ddg
 
     | alias1          =  
 
     | alias1          =  
 
     | alias2          =  
 
     | alias2          =  
Line 193: Line 193:
 
The template takes two positional parameters.
 
The template takes two positional parameters.
  
* The first positional parameter specifies the subtemplate for which data is requested. It may take the value of the subpage name of the link template (e.g. <code>gnews</code>), a value of ''linkn'' (<code>link1</code>, <code>link2</code>, etc.), or its alias ''ln'' (<code>l1</code>, <code>l2</code>, etc.). If this parameter is not specified, or the value is not valid, the template outputs a null value.
+
* The first positional parameter specifies the subtemplate for which data is requested. It may take the value of the subpage name of the link template (e.g. <code>gnews</code>), a value of ''linkn'' (<code>link1</code>, <code>link2</code>, etc.), or its alias ''ln'' (<code>l1</code>, <code>l2</code>, etc.).
 
* The second positional parameter specifies what type of data is requested. It can take the following values:
 
* The second positional parameter specifies what type of data is requested. It can take the following values:
 
** <code>code</code> - The main link code. This is the same as the subpage name of the link template.
 
** <code>code</code> - The main link code. This is the same as the subpage name of the link template.
Line 207: Line 207:
 
** <code>notes</code> - Notes about of the link template.
 
** <code>notes</code> - Notes about of the link template.
  
If the first positional parameter has a valid value, but the second positional parameter is absent or has an invalid value, the template will output the main link code for the link template specified by the first positional parameter. If both the first and second positional parameters have valid values, but no data is found, the template will output a null value.
+
The template will only output data if the following three conditions are all true:
 +
# The first positional parameter has a valid value.
 +
# The second positional parameter has a valid value.
 +
# The data field specified by the first and second positional parameters is not empty.
 +
Otherwise, the template will return a null value.
  
 
== Examples ==
 
== Examples ==
Line 252: Line 256:
 
:produces:
 
:produces:
 
:{{find sources multi/linkinfo|nonexistentvalue|code}}
 
:{{find sources multi/linkinfo|nonexistentvalue|code}}
 +
 +
== Adding new entries ==
 +
 +
Adding new entries should be fairly self-explanatory - just keep the format the same as previous entries.
  
 
}}
 
}}

Revision as of 09:47, 15 March 2013

Template documentation

This template stores data about the various search link subtemplates of {{find sources multi}}.

Usage

The template takes two positional parameters.

  • The first positional parameter specifies the subtemplate for which data is requested. It may take the value of the subpage name of the link template (e.g. gnews), a value of linkn (link1, link2, etc.), or its alias ln (l1, l2, etc.).
  • The second positional parameter specifies what type of data is requested. It can take the following values:
    • code - The main link code. This is the same as the subpage name of the link template.
    • alias1 - An alias for the main link code. The subpage of Template:Find sources multi with this value is a redirect to the link template.
    • alias2 - Another alias for the main link code.
    • alias3 - A third alias for the main link code.
    • alias4 - A fourth alias for the main link code.
    • t_description - A short description of the template.
    • se_description - A short description of the search engine that the template uses.
    • shortcut1 - A template shortcut for the link template.
    • shortcut2 - A second template shortcut for the link template.
    • shortcut3 - A third template shortcut for the link template.
    • notes - Notes about of the link template.

The template will only output data if the following three conditions are all true:

  1. The first positional parameter has a valid value.
  2. The second positional parameter has a valid value.
  3. The data field specified by the first and second positional parameters is not empty.

Otherwise, the template will return a null value.

Examples

Example 1
{{find sources multi/linkinfo|link1}}
produces:
Example 2
{{find sources multi/linkinfo|link1|code}}
produces:
g
Example 3
{{find sources multi/linkinfo|ddg|code}}
produces:
ddg
Example 4
{{find sources multi/linkinfo|link1|t_description}}
produces:
This template provides a search link to Google to help find sources for articles.
Example 5
{{find sources multi/linkinfo|ddg|se_description}}
produces:
DuckDuckGo, a search engine that uses information from crowd-sourced websites (such as Wikipedia) to provide its results.
Example 6
{{find sources multi/linkinfo|link1|nonexistentvalue}}
produces:
Example 7
{{find sources multi/linkinfo|nonexistentvalue|code}}
produces:

Adding new entries

Adding new entries should be fairly self-explanatory - just keep the format the same as previous entries.