Template:Wp/doc: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Updated documentation.)
(Updated /doc.)
Line 7: Line 7:


==Parameters==
==Parameters==
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>).
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>).


The syntax for the template is:
The syntax for the template is:


{{tlc|wp&#32;|''article name''&#32;|''alternative link text''&#32;|lang&#61;''language code''}}
{{tlc|wp&#32;|''article name''&#32;|''custom link text''&#32;|sect&#61;''article section/subheader''&#32;|lang&#61;''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.


===Article name===
===Article name===
Line 21: Line 19:


;<big>Limitations</big>
;<big>Limitations</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 ''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 ''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:
;Usage:
* <code><nowiki>{{</nowiki>wp|'''''article name'''''<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|'''article name'''<nowiki>}}</nowiki></code>


===Alternative link text===
===Custom link text===
''Optional''
''Optional''
* '''<code>2</code>''': Custom text
* '''<code>2</code>''': Custom text
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.
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>Limitations</big>
* The alternative link text must be placed '''after''' (to the right of) the ''article name'' parameter!
* The custom link text must be placed '''after''' (to the right of) the ''article name'' parameter!
 
;Usage:
* <code><nowiki>{{</nowiki>wp|''article name''|'''custom link text'''<nowiki>}}</nowiki></code>
 
===Article section/subheader===
''Optional''
* '''<code>sect</code>''': Article section/subheader title
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:
;Usage:
* <code><nowiki>{{</nowiki>wp|''article name''|'''''alternative link text'''''<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|''article name''|''custom link text''|'''sect&#61;'''section/subheader title<nowiki>}}</nowiki></code>


===Wikipedia language===
===Wikipedia language===
''Optional''
''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 (<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 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:
;Usage:
* <code><nowiki>{{</nowiki>wp|''article name''|''alternative link text''|'''lang&#61;'''language code<nowiki>}}</nowiki></code>
* <code><nowiki>{{</nowiki>wp|''article name''|''custom link text''|'''lang&#61;'''language code<nowiki>}}</nowiki></code>


==Examples==
==Examples==
Line 53: Line 60:
| Article name || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
| Article name || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| Alternative 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}}
|-
| rowspan="3" | Language: English || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| <code><nowiki>{{wp|Mozilla Foundation|lang=}}</nowiki></code> || {{wp|Mozilla Foundation|lang=}}
| 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}}
|-
|-
| <code><nowiki>{{wp|Mozilla Foundation|lang=en}}</nowiki></code> || {{wp|Mozilla Foundation|lang=en}}
| English is the default language || <code><nowiki>{{wp|Mozilla Foundation}}</nowiki></code> || {{wp|Mozilla Foundation}}
|-
|-
| Language: Swedish || <code><nowiki>{{wp|Mozilla Foundation|lang=sv}}</nowiki></code> || {{wp|Mozilla Foundation|lang=sv}}
| Choose language: Swedish || <code><nowiki>{{wp|Mozilla Foundation|lang=sv}}</nowiki></code> || {{wp|Mozilla Foundation|lang=sv}}
|-
| 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}}
|-
| <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 on Swedish Wikipedia|lang=sv}}</nowiki></code> || {{wp|Mozilla Foundation|Mozilla on Swedish Wikipedia|lang=sv}}
|}
|}


Line 73: Line 72:
{| class="wikitable"
{| class="wikitable"
|-
|-
! Example case !! What you write !! What you see (error)
! Example case !! What you write !! What you see !! Description
|-
| No parameter || <code><nowiki>{{wp}}</nowiki></code> || {{wp}} || Param name visible
|-
|-
| No parameter || <code><nowiki>{{wp}}</nowiki></code> || {{wp}}
| rowspan="2" | Empty first param || <code><nowiki>{{wp|}}</nowiki></code> || {{wp|}} || Unnamed link to Wikipedia's (en) main page
|-
|-
| rowspan="2" | Empty first param || <code><nowiki>{{wp|}}</nowiki></code> || {{wp|}}
| <code><nowiki>{{wp||Mozilla on Wikipedia}}</nowiki></code> || {{wp||Mozilla on Wikipedia}} || Links to Wikipedia's (en) main page
|-
|-
| <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|Custom link name|Article name}}</nowiki></code> || {{wp|Custom link name|Article name}} || Links to the custom text string instead of the desired article
|-
|-
| 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}}
| Inserted but empty <code>lang</code> param || <code><nowiki>{{wp|Mozilla Foundation|lang=}}</nowiki></code> || {{wp|Mozilla Foundation|lang=}} || Broken link
|}
|}



Revision as of 14:09, 21 November 2014

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 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 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 ({{{1}}}).

The syntax for the template is:

{{wp |article name |custom link text |sect=article section/subheader |lang=language code }}

Article name

Required

  • 1: The name of the Wikipedia article

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.

Limitations
  • 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.
  • This parameter ("1") must be placed before any custom link text (parameter "2"), otherwise they will switch functions.
Usage
  • {{wp|article name}}

Custom link text

Optional

  • 2: 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.

Limitations
  • The custom link text must be placed after (to the right of) the article name parameter!
Usage
  • {{wp|article name|custom link text}}

Article section/subheader

Optional

  • sect: Article section/subheader title

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 Article_name#Section_name. Just enter the name of the section, i.e. don't include the number sign (#). That is inserted automatically. As with the article name, this must be entered exactly as it is on the Wikipedia page. The "sect" parameter is not place sensitive.

Usage
  • {{wp|article name|custom link text|sect=section/subheader title}}

Wikipedia language

Optional

  • lang: Wikipedia language code

The link produced by {{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 list of Wikipedia language versions, complete with current language codes. The "lang" parameter is not place sensitive.

Usage
  • {{wp|article name|custom link text|lang=language code}}

Examples

Correct use

Example case What you write What you see
Article name {{wp|Mozilla Foundation}} Mozilla Foundation
Custom link text {{wp|Mozilla Foundation|Mozilla on Wikipedia}} Mozilla on Wikipedia
Link to an article section {{wp|Mozilla Foundation|Mozilla Corporation on Wikipedia|sect=Mozilla Corporation}} Mozilla Corporation on Wikipedia
English is the default language {{wp|Mozilla Foundation}} Mozilla Foundation
Choose language: Swedish {{wp|Mozilla Foundation|lang=sv}} Mozilla Foundation

Incorrect use

Example case What you write What you see Description
No parameter {{wp}} Wikipedia (en) Param name visible
Empty first param {{wp|}} Wikipedia (en) Unnamed link to Wikipedia's (en) main page
{{wp||Mozilla on Wikipedia}} Mozilla on Wikipedia Links to Wikipedia's (en) main page
Malplacement of params 1 and 2 {{wp|Custom link name|Article name}} Article name Links to the custom text string instead of the desired article
Inserted but empty lang param {{wp|Mozilla Foundation|lang=}} Mozilla Foundation Broken link

See also

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