Template:Wp/doc: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(.)
 
(16 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
__NOTOC__
__NOTOC__
<noinclude>{{Admon/important|Help needed|For some reason, any space character in 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]] ([[User talk:Lakrits|talk]])}}</noinclude>
==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 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 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.


The syntax looks like this:
===Syntax===
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;|''custom link text''&#32;|''language code''&#32;}}


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


====Article name====
;<big>Notes</big>
* '''<code>1</code>''': The name of the Wikipedia article
* 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 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.


;<big>Limitations</big>
;<big>Usage</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.
* <code><nowiki>{{</nowiki>wp|{{big|'''1'''}}<nowiki>}}</nowiki></code>
* 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:
====2====
* <code><nowiki>{{</nowiki>wp|'''1'''<nowiki>}}</nowiki></code>
;<big>Custom link text</big>
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.


====Alternate link text====
;<big>Notes</big>
* '''<code>2</code>''': Custom text
* 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}}.
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.
:Example: to create a link to the article ''Article'' in French Wikipedia, you type {{tlc|wp|Article{{!}}{{!}}fr}}.


;<big>Limitations</big>
;<big>Usage</big>
* The alternate link text must be placed '''after''' (to the right of) the ''article name'' parameter!
* <code><nowiki>{{</nowiki>wp|1|{{big|'''2'''}}<nowiki>}}</nowiki></code>


;Usage:
====3====
* <code><nowiki>{{</nowiki>wp|1|'''2'''<nowiki>}}</nowiki></code>
;<big>Wikipedia language code</big>
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.


====Wikipedia language====
;<big>Notes</big>
* '''<code>lang</code>''': Wikipedia language 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>}}".
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.
* 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)}}".


;Usage:
;<big>Usage</big>
* <code><nowiki>{{</nowiki>wp|1|2|'''lang&#61;'''language code<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|1|2|{{big|'''3'''}}<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
|-
|-
| Article name || <code><nowiki>{{wp|Mozilla}}</nowiki></code> || {{wp|Mozilla}}
| Simplest use || <code><nowiki>{{wp}}</nowiki></code> || {{wp}}
|-
|-
| Alternate link text || <code><nowiki>{{wp|Mozilla|Mozilla on Wikipedia}}</nowiki></code> || {{wp|Mozilla|Mozilla on Wikipedia}}
| Article name || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| rowspan="3" | Language: English || <code><nowiki>{{wp|Mozilla}}</nowiki></code> || {{wp|Mozilla}}
| Custom link text || <code><nowiki>{{wp|Mozilla Foundation|Mozilla on Wikipedia}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla on Wikipedia}}
|-
|-
| <code><nowiki>{{wp|Mozilla|lang=}}</nowiki></code> || {{wp|Mozilla|lang=}}
| English is the default language || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| <code><nowiki>{{wp|Mozilla|lang=en}}</nowiki></code> || {{wp|Mozilla|lang=en}}
| Choose language: French || <code><nowiki>{{wp|Mozilla Foundation||fr}}</nowiki></code> || {{wp|Mozilla Foundation||fr}}
|-
|-
| Language: Swedish || <code><nowiki>{{wp|Mozilla|lang=sv}}</nowiki></code> || {{wp|Mozilla|lang=sv}}
| rowspan="3" | Main Page: Swedish || <code><nowiki>{{wp|||sv}}</nowiki></code> || {{wp|||sv}}
|-
|-
| 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|Main Page||sv}}</nowiki></code> || {{wp|Main Page||sv}}
|-
|-
| <code><nowiki>{{wp|Mozilla|lang=sv|Mozilla on Swedish Wikipedia}}</nowiki></code> || {{wp|Mozilla|lang=sv|Mozilla on Swedish Wikipedia}}
| <code><nowiki>{{wp|Huvudsida||sv}}</nowiki></code> || {{wp|Huvudsida||sv}}
|-
| <code><nowiki>{{wp|Mozilla|Mozilla on Swedish Wikipedia|lang=sv}}</nowiki></code> || {{wp|Mozilla|Mozilla on Swedish Wikipedia|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="2" | Underscores in the article name || <code><nowiki>{{wp|Mozilla_Foundation}}</nowiki></code> || {{wp|Mozilla_Foundation}}
|-
| <code><nowiki>{{wp|Mozilla_Foundation|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla_Foundation|Mozilla Foundation}}
|}
|}


====Incorrect use====
==See also==
{| class="wikitable"
* {{tl|wikipedia}}: simple template for creating a link to English Wikipedia, based on the page name.
|-
! Example case !! What you write !! What you see
|-
| No parameter || <code><nowiki>{{wp}}</nowiki></code> || {{wp}}
|-
| rowspan="2" | Empty first param || <code><nowiki>{{wp|}}</nowiki></code> || {{wp|}}
|-
| <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|allizoM|Mozilla}}</nowiki></code> || {{wp|allizoM|Mozilla}}
|-
| Spaces in the article name || <code><nowiki>{{wp|Mozilla Foundation|Mozilla, the foundation}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla, the foundation}}
|}


==See also==
* {{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.