Template:Wp/doc: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Updated /doc.)
 
(10 intermediate revisions by the same user not shown)
Line 2: Line 2:
__NOTOC__
__NOTOC__
==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 interwiki 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.


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 four parameters – two named and two unnamed. The first unnamed parameter is required. If no parameters at all are entered, the template will output a link to the English Wikipedia main page, with the template's first parameter as the link name (<code>{{{1}}}</code>).
There are 3 parameters, all unnamed and optional. If no parameters at all are entered, the template will output a link to the English Wikipedia main page.


===Syntax===
The syntax for the template is:
The syntax for the template is:


{{tlc|wp&#32;|''article name''&#32;|''custom link text''&#32;|sect&#61;''article section/subheader''&#32;|lang&#61;''language code''&#32;}}
{{tlc|wp&#32;|''article name''&#32;|''custom link text''&#32;|''language code''&#32;}}


===Article name===
===Optional parameters===
''Required''
====1====
* '''<code>1</code>''': The name of the Wikipedia article
;<big>Article name</big>
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.
This is the parameter for entering the name of the article on Wikipedia, you wish to link to.


;<big>Limitations</big>
;<big>Notes</big>
* 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 ''custom 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||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 ''custom link text'' parameter.
* This parameter ("<code>1</code>") must be placed '''before''' any custom link text (parameter "<code>2</code>"), otherwise they will switch functions.


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


===Custom link text===
====2====
''Optional''
;<big>Custom link text</big>
* '''<code>2</code>''': Custom text
With this parameter, you can define an custom 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 custom text string to be shown instead of the Wikipedia article's name. No parameter name needs to be entered.


;<big>Limitations</big>
;<big>Notes</big>
* The custom link text must be placed '''after''' (to the right of) the ''article name'' parameter!
* To skip this parameter, and only use the 1st and the 3rd parameters, leave it empty by typing two pipes in a row, following the syntax {{tlc|wp|1{{!}}{{small|(empty)}}{{!}}3}}.
:Example: to create a link to the article ''Article'' in French Wikipedia, you type {{tlc|wp|Article{{!}}{{!}}fr}}.


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


===Article section/subheader===
====3====
''Optional''
;<big>Wikipedia language code</big>
* '''<code>sect</code>''': Article section/subheader title
The link produced by {{tlf|wp}} leads, by default, to English Wikipedia (<tt>en.wikipedia.org</tt>). If you want to link to another 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.
This parameter allow you to link to a named section of an article, i.e. a subheader or an anchor. Together with the ''article name'' it will produde a combined wikilink in the format <code>Article_name#Section_name</code>. Just enter the name of the section, i.e. don't include the number sign (<code>#</code>). That is inserted automatically. As with the ''article name'', this must be entered exactly as it is on the Wikipedia page. The "<code>sect</code>" parameter is not place sensitive.


;Usage:
;<big>Notes</big>
* <code><nowiki>{{</nowiki>wp|''article name''|''custom link text''|'''sect&#61;'''section/subheader title<nowiki>}}</nowiki></code>
* The use of interwiki links means, in this case, that the output link will point to the English Wikipedia server, and then be redirected from there to the language server you have specified. If, for example, the template is instructed to produce a link to the article ''Article'' in French Wikipedia, it will produce the link "{{code|<nowiki>https://en.wikipedia.org/wiki/fr:Article</nowiki>}}", but when you click it, you will go to the address "{{code|<nowiki>https://fr.wikipedia.org/wiki/Article</nowiki>}}".
* To produce a link to the main page for a specific language, you skip the first two parameters. Leave them empty by typing three pipes in a row, following the syntax {{tlc|wp|{{small|(empty)}}{{!}}{{small|(empty)}}{{!}}3}}. The template will output the link with the link text "{{samp|Wikipedia (lang. code)}}".
:Example: to create a link to the main page for French Wikipedia, you type {{tlc|wp|{{!}}{{!}}fr}}. The result will be a link with the link text "{{samp|Wikipedia (fr)}}".


===Wikipedia language===
;<big>Usage</big>
''Optional''
* <code><nowiki>{{</nowiki>wp|1|2|{{big|'''3'''}}<nowiki>}}</nowiki></code>
* '''<code>lang</code>''': Wikipedia language code
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. The "<code>lang</code>" parameter is not place sensitive.
 
;Usage:
* <code><nowiki>{{</nowiki>wp|''article name''|''custom link text''|'''lang&#61;'''language code<nowiki>}}</nowiki></code>


==Examples==
==Examples==
===Correct use===
{| class="wikitable" style="background-color: white;"
{| class="wikitable"
|-
|-
! Example case !! What you write !! What you see
! Example case !! What you write !! What you see
|-
| Simplest use || <code><nowiki>{{wp}}</nowiki></code> || {{wp}}
|-
|-
| Article name || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
| Article name || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| Custom link text || <code><nowiki>{{wp|Mozilla Foundation|Mozilla on Wikipedia}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla on Wikipedia}}
| Custom link text || <code><nowiki>{{wp|Mozilla Foundation|Mozilla on Wikipedia}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla on Wikipedia}}
|-
| Link to an article section || <code><nowiki>{{wp|Mozilla Foundation|Mozilla Corporation on Wikipedia|sect=Mozilla Corporation}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla Corporation on Wikipedia|sect=Mozilla Corporation}}
|-
|-
| English is the default language || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
| English is the default language || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| Choose language: Swedish || <code><nowiki>{{wp|Mozilla Foundation|lang=sv}}</nowiki></code> || {{wp|Mozilla Foundation|lang=sv}}
| Choose language: French || <code><nowiki>{{wp|Mozilla Foundation||fr}}</nowiki></code> || {{wp|Mozilla Foundation||fr}}
|}
 
===Incorrect use===
{| class="wikitable"
|-
|-
! Example case !! What you write !! What you see !! Description
| rowspan="3" | Main Page: Swedish || <code><nowiki>{{wp|||sv}}</nowiki></code> || {{wp|||sv}}
|-
|-
| No parameter || <code><nowiki>{{wp}}</nowiki></code> || {{wp}} || Param name visible
| <code><nowiki>{{wp|Main Page||sv}}</nowiki></code> || {{wp|Main Page||sv}}
|-
|-
| rowspan="2" | Empty first param || <code><nowiki>{{wp|}}</nowiki></code> || {{wp|}} || Unnamed link to Wikipedia's (en) main page
| <code><nowiki>{{wp|Huvudsida||sv}}</nowiki></code> || {{wp|Huvudsida||sv}}
|-
| <code><nowiki>{{wp||Mozilla on Wikipedia}}</nowiki></code> || {{wp||Mozilla on Wikipedia}} || Links to Wikipedia's (en) main 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}} || Links to the custom text string instead of the desired article
|-
| Inserted but empty <code>lang</code> param || <code><nowiki>{{wp|Mozilla Foundation|lang=}}</nowiki></code> || {{wp|Mozilla Foundation|lang=}} || Broken link
|}
|}


==See also==
==See also==
* {{tl|wikipedia}} simple template for creating a link to English Wikipedia, based on the page name.
* {{tl|wikipedia}}: simple template for creating a link to English Wikipedia, based on the page name.
 


<includeonly>
<includeonly>
{{#ifeq:{{SUBPAGENAME}}|sandbox||
<!-- Add categories below, please -->
[[Category:External link templates]]
[[Category:External link templates]]
}}
</includeonly>
</includeonly>

Latest revision as of 22:02, 24 January 2015

Edit-copy green.svg
This is a documentation subpage for Template:Wp.
It contains usage information, categories and other content that is not part of the original template page.

Usage

{{wp}} creates a customized, named interwiki 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.

The template is useful for easy linking to Wikipedia articles in any of the available Wikipedia language servers.

Parameters

There are 3 parameters, all unnamed and optional. If no parameters at all are entered, the template will output a link to the English Wikipedia main page.

Syntax

The syntax for the template is:

{{wp |article name |custom link text |language code }}

Optional parameters

1

Article name

This is the parameter for entering the name of the article on Wikipedia, you wish to link to.

Notes
  • 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, "Hovrätt", you have to write Hovrätt, and not Hovratt, Hovraett, or Court of appeal). If you want the link to show something other than the article's name, use the custom link text parameter.
Usage
  • {{wp|1}}

2

Custom link text

With this parameter, you can define an custom text string to be shown instead of the Wikipedia article's name. No parameter name needs to be entered.

Notes
  • To skip this parameter, and only use the 1st and the 3rd parameters, leave it empty by typing two pipes in a row, following the syntax {{wp|1|(empty)|3}}.
Example: to create a link to the article Article in French Wikipedia, you type {{wp|Article||fr}}.
Usage
  • {{wp|1|2}}

3

Wikipedia language code

The link produced by {{wp}} leads, by default, to English Wikipedia (en.wikipedia.org). If you want to link to another 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 list of Wikipedia language versions, complete with current language codes.

Notes
  • The use of interwiki links means, in this case, that the output link will point to the English Wikipedia server, and then be redirected from there to the language server you have specified. If, for example, the template is instructed to produce a link to the article Article in French Wikipedia, it will produce the link "https://en.wikipedia.org/wiki/fr:Article", but when you click it, you will go to the address "https://fr.wikipedia.org/wiki/Article".
  • To produce a link to the main page for a specific language, you skip the first two parameters. Leave them empty by typing three pipes in a row, following the syntax {{wp|(empty)|(empty)|3}}. The template will output the link with the link text "Wikipedia (lang. code)".
Example: to create a link to the main page for French Wikipedia, you type {{wp|||fr}}. The result will be a link with the link text "Wikipedia (fr)".
Usage
  • {{wp|1|2|3}}

Examples

Example case What you write What you see
Simplest use {{wp}} Wikipedia (en)
Article name {{wp|Mozilla Foundation}} Mozilla Foundation
Custom link text {{wp|Mozilla Foundation|Mozilla on Wikipedia}} Mozilla on Wikipedia
English is the default language {{wp|Mozilla Foundation}} Mozilla Foundation
Choose language: French {{wp|Mozilla Foundation||fr}} Mozilla Foundation
Main Page: Swedish {{wp|||sv}} Wikipedia (sv)
{{wp|Main Page||sv}} Main Page
{{wp|Huvudsida||sv}} Huvudsida

See also

  • {{wikipedia}}: simple template for creating a link to English Wikipedia, based on the page name.