Template:Wp/doc: Difference between revisions

Updated documentation.
(Updated documentation.)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
__NOTOC__
__NOTOC__
{{Admon/important|Help needed|For some reason, any space character in the value of the first unnamed parameter breaks the template, cutting the link short and inserting the rest of the string at the start of the second unnamed parameter. I can't get it to work, but maybe you can. /[[User:Lakrits|Lakrits]]}}
==Usage==
==Usage==
{{tl|wp}} creates a customized, named link to a Wikipedia article at the position where you place the template. It is possible to choose a Wikipedia language server and to replace the article's name with a custom link text.
{{tl|wp}} creates a customized, named link to a Wikipedia article at the position where you place the template. It is possible to choose a Wikipedia language server and to replace the article's name with a custom link text.
Line 8: Line 6:
The template is useful for easy linking to Wikipedia articles in any of the available Wikipedia language servers.
The template is useful for easy linking to Wikipedia articles in any of the available Wikipedia language servers.


===Parameters===
==Parameters==
There are three parameters – one named and two unnamed, none of which is strictly mandatory. However, the '''article name''' (unnamed parameter "<code>1</code>") is required for the template to be at all useful, and is therefore '''strongly recommended'''. If no parameters at all are entered, the template will output an empty, numbered link to English Wikipedia's main page.
There are three parameters – one named and two unnamed. The first unnamed parameter is required. If no parameters at all are entered, the template will output a link to English Wikipedia's main page, with the template's first parameter as its name (<code>{{{1}}}</code>).


The syntax looks like this:
The syntax for the template is:


{{tlc|wp&#32;|''article name''&#32;|''alternate link text''&#32;|lang&#61;''language code''}}
{{tlc|wp&#32;|''article name''&#32;|''alternative link text''&#32;|lang&#61;''language code''}}


'''NB!''' The ''article name'' (parameter "<code>1</code>") must be placed '''before''' any custom link text (parameter "<code>2</code>"), otherwise they will switch functions. The "<code>lang</code>" parameter is not place sensitive.
'''NB!''' The ''article name'' (parameter "<code>1</code>") must be placed '''before''' any custom link text (parameter "<code>2</code>"), otherwise they will switch functions. The "<code>lang</code>" parameter is not place sensitive.


====Article name====
===Article name===
''Required''
* '''<code>1</code>''': The name of the Wikipedia article
* '''<code>1</code>''': The name of the Wikipedia article
This is the parameter for entering the name of the article on Wikipedia, you wish to link to. It is not a mandatory parameter, but highly recommended. No parameter name needs to be entered.
This is the parameter for entering the name of the article on Wikipedia, you wish to link to. No parameter name needs to be entered.


;<big>Limitations</big>
;<big>Limitations</big>
* For some reason, the template cuts at the first space character in the article name. If the article has more than one word in its name, you need to '''replace the spaces with underscores''' ("_"), and then use the ''alternate link text'' parameter to show the article name with spaces.
* The article name has to be written exactly as it is on the Wikipedia page; i.e. with diacritics and not translated (e.g. for the Swedish Wikipedia article on the Swedish judicial system's courts of appeal, "{{wp|Hovrätt|lang=sv}}", you have to write <tt>Hovrätt</tt>, and not <tt>Hovratt</tt>, <tt>Hovraett</tt>, or <tt>Court of appeal</tt>). If you want the link to show something other than the article's name, use the ''alternative link text'' parameter.
* The article name has to be written exactly as it is on the Wikipedia page; i.e. with diacritics and not translated (e.g. for the Swedish Wikipedia article on the Swedish judicial system's courts of appeal, "{{wp|Hovrätt|lang=sv}}", you have to write <tt>Hovrätt</tt>, and not <tt>Hovratt</tt>, <tt>Hovraett</tt>, or <tt>Court of appeal</tt>). If you want the link to show something other than the article's name, use the ''alternate link text'' parameter.


;Usage:
;Usage:
* <code><nowiki>{{</nowiki>wp|'''1'''<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|'''''article name'''''<nowiki>}}</nowiki></code>


====Alternate link text====
===Alternative link text===
''Optional''
* '''<code>2</code>''': Custom text
* '''<code>2</code>''': Custom text
With this parameter, you can define an alternate text string to be shown instead of the Wikipedia article's name. No parameter name needs to be entered.
With this parameter, you can define an alternative text string to be shown instead of the Wikipedia article's name. No parameter name needs to be entered.


;<big>Limitations</big>
;<big>Limitations</big>
* The alternate link text must be placed '''after''' (to the right of) the ''article name'' parameter!
* The alternative link text must be placed '''after''' (to the right of) the ''article name'' parameter!


;Usage:
;Usage:
* <code><nowiki>{{</nowiki>wp|1|'''2'''<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|''article name''|'''''alternative link text'''''<nowiki>}}</nowiki></code>


====Wikipedia language====
===Wikipedia language===
''Optional''
* '''<code>lang</code>''': Wikipedia language code
* '''<code>lang</code>''': Wikipedia language code
The link produced by {{tl|wp}} leads by default to English Wikipedia (en.wikipedia.org). If you want to link to a different language version of Wikipedia (e.g. Swedish Wikipedia (sv.wikipedia.org), you can use this parameter and enter the language code for the Wikipedia you wish to link to. Here's a {{wp|List_of_Wikipedias|list of Wikipedia language versions}}, complete with current language codes.
The link produced by {{tl|wp}} leads by default to English Wikipedia (<tt>en.wikipedia.org</tt>). If you want to link to a different language version of Wikipedia, e.g. Swedish Wikipedia (<tt>sv.wikipedia.org</tt>), you can use this parameter and enter the language code for the Wikipedia you wish to link to. Here's a {{wp|List of Wikipedias|list of Wikipedia language versions}}, complete with current language codes.


;Usage:
;Usage:
* <code><nowiki>{{</nowiki>wp|1|2|'''lang&#61;'''language code<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|''article name''|''alternative link text''|'''lang&#61;'''language code<nowiki>}}</nowiki></code>


===Examples===
==Examples==
====Correct use====
===Correct use===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Example case !! What you write !! What you see
! Example case !! What you write !! What you see
|-
|-
| Article name || <code><nowiki>{{wp|Mozilla}}</nowiki></code> || {{wp|Mozilla}}
| Article name || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
| Alternate link text || <code><nowiki>{{wp|Mozilla|Mozilla on Wikipedia}}</nowiki></code> || {{wp|Mozilla|Mozilla on Wikipedia}}
|-
| rowspan="3" | Language: English || <code><nowiki>{{wp|Mozilla}}</nowiki></code> || {{wp|Mozilla}}
|-
| <code><nowiki>{{wp|Mozilla|lang=}}</nowiki></code> || {{wp|Mozilla|lang=}}
|-
|-
| <code><nowiki>{{wp|Mozilla|lang=en}}</nowiki></code> || {{wp|Mozilla|lang=en}}
| Alternative link text || <code><nowiki>{{wp|Mozilla Foundation|Mozilla on Wikipedia}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla on Wikipedia}}
|-
|-
| Language: Swedish || <code><nowiki>{{wp|Mozilla|lang=sv}}</nowiki></code> || {{wp|Mozilla|lang=sv}}
| rowspan="3" | Language: English || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| rowspan="3" | Placement of param "<code>lang</code>" is irrelevant || <code><nowiki>{{wp|lang=sv|Mozilla|Mozilla on Swedish Wikipedia}}</nowiki></code> || {{wp|lang=sv|Mozilla|Mozilla on Swedish Wikipedia}}
| <code><nowiki>{{wp|Mozilla Foundation|lang=}}</nowiki></code> || {{wp|Mozilla Foundation|lang=}}
|-
|-
| <code><nowiki>{{wp|Mozilla|lang=sv|Mozilla on Swedish Wikipedia}}</nowiki></code> || {{wp|Mozilla|lang=sv|Mozilla on Swedish Wikipedia}}
| <code><nowiki>{{wp|Mozilla Foundation|lang=en}}</nowiki></code> || {{wp|Mozilla Foundation|lang=en}}
|-
|-
| <code><nowiki>{{wp|Mozilla|Mozilla on Swedish Wikipedia|lang=sv}}</nowiki></code> || {{wp|Mozilla|Mozilla on Swedish Wikipedia|lang=sv}}
| Language: Swedish || <code><nowiki>{{wp|Mozilla Foundation|lang=sv}}</nowiki></code> || {{wp|Mozilla Foundation|lang=sv}}
|-
|-
| Link to Wikipedia page section || <code><nowiki>{{wp|Mozilla#Webmaker|Mozilla Webmaker on Wikipedia}}</nowiki></code> || {{wp|Mozilla#Webmaker|Mozilla Webmaker on Wikipedia}}
| rowspan="3" | Placement of param "<code>lang</code>" is irrelevant || <code><nowiki>{{wp|lang=sv|Mozilla Foundation|Mozilla on Swedish Wikipedia}}</nowiki></code> || {{wp|lang=sv|Mozilla Foundation|Mozilla on Swedish Wikipedia}}
|-
|-
| rowspan="2" | Underscores in the article name || <code><nowiki>{{wp|Mozilla_Foundation}}</nowiki></code> || {{wp|Mozilla_Foundation}}
| <code><nowiki>{{wp|Mozilla Foundation|lang=sv|Mozilla on Swedish Wikipedia}}</nowiki></code> || {{wp|Mozilla Foundation|lang=sv|Mozilla on Swedish Wikipedia}}
|-
|-
| <code><nowiki>{{wp|Mozilla_Foundation|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla_Foundation|Mozilla Foundation}}
| <code><nowiki>{{wp|Mozilla Foundation|Mozilla on Swedish Wikipedia|lang=sv}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla on Swedish Wikipedia|lang=sv}}
|}
|}


====Incorrect use====
===Incorrect use===
{| class="wikitable"
{| class="wikitable"
|-
|-
! Example case !! What you write !! What you see
! Example case !! What you write !! What you see (error)
|-
|-
| No parameter || <code><nowiki>{{wp}}</nowiki></code> || {{wp}}
| No parameter || <code><nowiki>{{wp}}</nowiki></code> || {{wp}}
Line 87: Line 81:
| <code><nowiki>{{wp||Mozilla on Wikipedia}}</nowiki></code> || {{wp||Mozilla on Wikipedia}}
| <code><nowiki>{{wp||Mozilla on Wikipedia}}</nowiki></code> || {{wp||Mozilla on Wikipedia}}
|-
|-
| Malplacement of params <code>1</code> and <code>2</code> || <code><nowiki>{{wp|Text|Page}}</nowiki></code> || {{wp|Text|Page}}
| Malplacement of params <code>1</code> and <code>2</code> || <code><nowiki>{{wp|Custom link name|Article name}}</nowiki></code> || {{wp|Custom link name|Article name}}
|-
| Spaces in the article name || <code><nowiki>{{wp|Mozilla Foundation|Mozilla, the foundation}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla, the foundation}}
|}
|}


3,860

edits