Changes

Jump to: navigation, search

Help:Variable

12,679 bytes added, 06:49, 25 April 2006
no edit summary
[[Category:Help]]{{Editor toc}}
This is a list of '''variables''' that can be used in the wikitext. The way they are rendered depends on the time, on the project, or on the page in which it occurs.

On the left is the variable, on the right how it is rendered at this time, in this project, on this page.

The names of the variables form part of the set of so-called "[[Help:Magic words|magic words]]" the system uses. [http://cvs.sourceforge.net/viewcvs.py/wikipedia/phase3/includes/MagicWord.php]

==Constant, only depending on the project and parameters==
{|
| <nowiki>{{ns:-2}} or {{ns:Media}}</nowiki>
| {{ns:-2}}
|-
| <nowiki>{{ns:-1}} or {{ns:Special}}</nowiki>
| {{ns:-1}}
|-
| <nowiki>{{ns:1}} or {{ns:Talk}}</nowiki>
| {{ns:1}}
|-
| <nowiki>{{ns:2}} or {{ns:User}}</nowiki>
| {{ns:2}}
|-
| <nowiki>{{ns:3}} or {{ns:User_talk}}</nowiki>
| {{ns:3}}
|-
| <nowiki>{{ns:4}} or {{ns:Project}}</nowiki>
| {{ns:4}}
|-
| <nowiki>{{ns:5}} or {{ns:Project_talk}}</nowiki>
| {{ns:5}}
|-
| <nowiki>{{ns:6}} or {{ns:Image}}</nowiki>
| {{ns:6}}
|-
| <nowiki>{{ns:7}} or {{ns:Image_talk}}</nowiki>
| {{ns:7}}
|-
| <nowiki>{{ns:8}} or {{ns:MediaWiki}}</nowiki>
| {{ns:8}}
|-
| <nowiki>{{ns:9}} or {{ns:MediaWiki_talk}}</nowiki>
| {{ns:9}}
|-
| <nowiki>{{ns:10}} or {{ns:Template}}</nowiki>
| {{ns:10}}
|-
| <nowiki>{{ns:11}} or {{ns:Template_talk}}</nowiki>
| {{ns:11}}
|-
| <nowiki>{{ns:12}} or {{ns:Help}}</nowiki>
| {{ns:12}}
|-
| <nowiki>{{ns:13}} or {{ns:Help_talk}}</nowiki>
| {{ns:13}}
|-
| <nowiki>{{ns:14}} or {{ns:Category}}</nowiki>
| {{ns:14}}
|-
| <nowiki>{{ns:15}} or {{ns:Category_talk}}</nowiki>
| {{ns:15}}
|-
| depending on custom namespaces: <br><nowiki>{{ns:100}}, {{ns:101}}, etc.</nowiki>
| {{ns:100}}, {{ns:101}}, etc.
|-
|-
| <nowiki>{{SITENAME}}</nowiki>
| {{SITENAME}}
|-
| <nowiki>{{SERVER}}</nowiki>
| {{SERVER}}
|-
| <nowiki>{{SERVERNAME}}</nowiki>
| {{SERVERNAME}}
|-
| <nowiki>{{localurl:pagename}}</nowiki>
| {{localurl:pagename}}
|-
| <nowiki>{{localurle:pagename}}</nowiki>
| {{localurle:pagename}}
|-
| <nowiki>{{localurl:pagename|</nowiki>''query string''<nowiki>}}</nowiki>
| {{localurl:pagename|''query string''}}
|-
| <nowiki>{{fullurl:pagename}}</nowiki>
| {{fullurl:pagename}}
|-
| <nowiki>{{fullurl:pagename|</nowiki>''query_string''<nowiki>}}</nowiki>
| {{fullurl:pagename|query_string}}
|-
| <nowiki>{{int:fromwikipedia}}</nowiki>
| {{int:fromwikipedia}}

|}


The variable localurl replaces spaces by underscores and special characters by escape codes, e.g. <nowiki>{{</nowiki>localurl:a é}} gives {{localurl:a é}}. The purposes are:
*for a given page name, creating a link in external link style to a page in the same project or a project which uses the same string in the URL between the server name and the page name (on Wikimedia "/wiki/" and "w/index.php?title=") (but see also [[m:Template talk:Pi]]).
*allow the same wikitext to be used in a project that uses a different string, if the target is in that other project or a project which uses the same string

The pagename in localurl should not be written with escape codes: e.g. use <nowiki>{{SERVER}}{{localurl:À}}</nowiki> giving {{SERVER}}{{localurl:À}}, not <nowiki>{{SERVER}}{{localurl:%C3%80}}</nowiki> giving {{SERVER}}{{localurl:%C3%80}} .

Note that localurl does ''not'' convert page names and user names after "target=". This syntax can be avoided by putting the target in the first part of localurl, after the "/":

*<nowiki>http://fr.wikipedia.org{{localurl:Special:Recentchangeslinked/Économie de Monaco|hideminor=0&days=100&limit=50}}</nowiki> gives:
**http://fr.wikipedia.org{{localurl:Special:Recentchangeslinked/Économie de Monaco|hideminor=0&days=100&limit=50}}
*<nowiki>http://en.wikipedia.org{{localurl:Special:Contributions/Jimbo Wales|limit=10&offset=200}}</nowiki> gives:
**http://en.wikipedia.org{{localurl:Special:Contributions/Jimbo Wales|limit=10&offset=200}}

Localurle (and its counterpart, fullurle) perform additional character escaping on the resulting link, and are intended for internal use only, and work in wikitext only for backwards-compatibility reasons. The unescaped versions should always be used in wikitext.

The <nowiki>{{fullurl}}</nowiki> variable introduced in recent versions allows the entire link to be specified in one go, without also using <nowiki>{{server}}</nowiki>. This also means it can be used in the same way for local and interwiki links (it being clearly inappropriate to add <nowiki>{{server}}</nowiki> before the latter)

Using {{tcw|url}}, instead of using SERVER and localurl, one can also use e.g. <nowiki>{{url}}abc&action=edit</nowiki> giving {{url}}abc&action=edit.

"INT:" is used to get text from the Mediawiki: namespace. If the user's interface language, as specified in Special:Preferences, is the wiki's default language, it will display the contents of [[Mediawiki:pagename]]. If the user has selected another language, it will display the contents of [[Mediawiki:pagename/languagecode]] (e.g. [[Mediawiki:fromwikipedia/fr]] for French) if such a page exists, and of [[Mediawiki:pagename]] if it does not. It is short for "internal".

==Varying with time==
{|
|-
|<nowiki>{{CURRENTMNTH}}</nowiki>
|{{CURRENTMNTH}}
| --One digit when month is below 10; en.wikipedia only, see {{tiw|en|CURRENTMNTH}}.
|-
|<nowiki>{{CURRENTMONTH}}</nowiki>
|{{CURRENTMONTH}}
| --Two-digit month number.
|-
|<nowiki>{{CURRENTMONTHNAME}}</nowiki>
|{{CURRENTMONTHNAME}}
|-
|<nowiki>{{CURRENTMONTHABBREV}}</nowiki>
|{{CURRENTMONTHABBREV}}
|-
|<nowiki>{{CURRENTMONTHNAMEGEN}}</nowiki>
|{{CURRENTMONTHNAMEGEN}}
|-
|<nowiki>{{CURRENTWEEK}}</nowiki>
|{{CURRENTWEEK}}
|-
|<nowiki>{{CURRENTDAY}}</nowiki>
|{{CURRENTDAY}}
| --One digit when day is below 10.
|-
|<nowiki>{{CURRENTDAY2}}</nowiki>
|{{CURRENTDAY2}}
| --Two-digit day of month; requires additional templates, see {{tim|CURRENTDAY2}}.
|-
|<nowiki>{{CURRENTDAYNAME}}</nowiki>
|{{CURRENTDAYNAME}}
|-
|<nowiki>{{CURRENTDOW}}</nowiki>
|{{CURRENTDOW}}
| --One-digit day of the week; 0=Sunday, 1=Monday ... 6=Saturday
|-
|<nowiki>{{CURRENTYEAR}}</nowiki>
|{{CURRENTYEAR}}
|-
|<nowiki>{{CURRENTTIME}}</nowiki>
|{{CURRENTTIME}}
|-
|<nowiki>{{NUMBEROFARTICLES}}</nowiki>
|{{NUMBEROFARTICLES}}
|-
|<nowiki>{{NUMBEROFFILES}}</nowiki>
|{{NUMBEROFFILES}}
|}

NUMBEROFARTICLES: number of pages in the main namespace which contain a link and are not a redirect, i.e. number of articles, stubs containing a link, and disambiguation pages.

This depends on system variable $wgUseCommaCount If true, article count will only include those with commas (","). If false, will only count those with links ("[["). The default set in DefaultSettings.php is false, this can be changed in LocalSettings.php. See also [[Help:Article count]].

CURRENTWEEK is not supported in earlier versions of MediaWiki. It ranges from 1 to 54.

CURRENTMONTHNAMEGEN: is the genitive grammatical form of the month name (used in Finnish).

See also {{tim|Short DOW}}.

===Subst===
When a template containing <nowiki>{{<includeonly>subst:</includeonly>CURRENTDAY}}</nowiki> is subst'ed, the day of doing that is put in the wikitext, and similarly for other variables.

==Depending on page==

{|
|<nowiki>{{NAMESPACE}}</nowiki>
|{{NAMESPACE}}
|-
|<nowiki>{{NAMESPACEE}}</nowiki>
|{{NAMESPACEE}}
|-
|<nowiki>{{PAGENAME}}</nowiki>
|{{PAGENAME}}
|-
|<nowiki>{{PAGENAMEE}}</nowiki>
|{{PAGENAMEE}}
|-
|<nowiki>{{FULLPAGENAME}}</nowiki>
|{{FULLPAGENAME}}
|-
|<nowiki>{{FULLPAGENAMEE}}</nowiki>
|{{FULLPAGENAMEE}}
|}

<nowiki>{{NAMESPACE}}</nowiki> and <nowiki>{{NAMESPACEE}}</nowiki> both return nothing (not even a space) in the article namespace. Thus, <nowiki>{{NAMESPACE}}{{PAGENAME}}</nowiki> is equivalent to <nowiki>{{FULLPAGENAME}}</nowiki>, and likewise for <nowiki>{{NAMESPACEE}}{{PAGENAMEE}}</nowiki>.

PAGENAMEE displays the page title in the form that is used in URLs, i.e. with underscores for spaces, and escape codes for special characters, and is therefore used for constructing URLs. For example, on a page called "Grand café", PAGENAMEE would produce "Grand_caf%C3%A9". Do not use PAGENAMEE as the pagename in first part of the variable localurl, see above. See also [[Help:Page name#Variables PAGENAME and PAGENAMEE|<nowiki>Variables PAGENAME and PAGENAMEE</nowiki>]].

When used in a [[help:template|template]], these three variables refer to the page in which the template is included, not to the template page.

===Subst===
When a template containing <nowiki>{{<includeonly>subst:</includeonly>PAGENAME}}</nowiki> is subst'ed in a page, the name of the latter page is put in the wikitext, and similarly for other variables.

== Depending on revision ==

<nowiki>{{REVISIONID}}</nowiki> gives {{REVISIONID}}

REVISIONID displays a unique number identifying a version of a page in the set of all versions of all pages. In the URL the number can be referred to as "old_id<nowiki>=</nowiki>..", even when the version is still the current one. This can be useful on talk pages, and for citation in newspaper, scholar works, etc. When applying such a URL, at the top of the page the date and local time (if not logged in: UTC) are displayed, with a link to the previous version, and a link to the next version (unless at the time of loading the page there is no newer version: in that case the text "Newer revision" appears anyway, but it is not a link; if the version is the first, a link labeled "previous revision" appears anyway, but it leads to the same page)

The [[Help:Page history|page history]] page also uses such a URL.

In a preview the value of REVISIONID is 0.

==Examples of combinations==

<table>
<tr><td><nowiki>{{fullurl:{{FULLPAGENAME}}|</nowiki>action=edit<nowiki>}}</nowiki>
<td>{{fullurl:{{FULLPAGENAME}}|action=edit}}
<tr><td><nowiki>{{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}</nowiki><td>{{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}
<tr><td><nowiki>{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|</nowiki>action=edit<nowiki>}}</nowiki>
<td>{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|action=edit}}
<tr><td><nowiki>{{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}</nowiki><td>{{SERVER}}{{localurl:Special:Whatlinkshere|target={{NAMESPACE}}:{{PAGENAME}}}}
<tr><td><nowiki>[[{{NAMESPACE}}:{{PAGENAME}}_1]]</nowiki>
<td>[[{{NAMESPACE}}:{{PAGENAME}}_1]]
<tr><td><nowiki>{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}_1}}</nowiki>
<td>{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}_1}}
<tr><td><nowiki>{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|oldid={{REVISIONID}}}}</nowiki>
<td>{{SERVER}}{{localurl:{{NAMESPACE}}:{{PAGENAME}}|oldid={{REVISIONID}}}}
</table>

''[Note that <code><nowiki>{{SERVER}}{{localurl...</nowiki></code> can be replaced by <code><nowiki>{{fullurl...</nowiki></code> in recent (>1.5.5) versions of the software.]''

As a link the last example is not useful in the page itself, but it gives useful info about the original in a paper or HTML copy of the page, and provides a link to that in the HTML copy. Also the rendered URL can be copied to the wikitext of this or another page, to refer to the version at the time of copying, e.g. http://meta.wikimedia.org/w/index.php?title=Help:Variable&oldid=178844 (For the latter purpose one can also use the link targets on the page history page).

As mentioned above, PAGENAME with single E has to be used within localurl, otherwise it does not work with special characters. For example, for a page named É we get <nowiki>{{localurl:É}}</nowiki>, which correctly gives {{localurl:É}} (with <nowiki>{{SERVER}}</nowiki> in front {{SERVER}}{{localurl:É}}, linking to the page É), while <nowiki>{{PAGENAMEE}}</nowiki> gives %C9, and <nowiki>{{localurl:%C9}}</nowiki> gives {{localurl:%C9}}, i.e. it is rendered unchanged, the function localurl is not applied. With <nowiki>{{SERVER}}</nowiki> in front it gives {{SERVER}}{{localurl:%C9}}, which is a dead link reported by the browser, the server is not even reached.

In a template, for a link to a page which depends on a template parameter, the external link style is used even for internal links, to avoid that the system links to the edit page even if the page exists. To construct the external link, variables can also be useful.

==Variables in links==

Variables work also in links:

*<nowiki>[[a{{NAMESPACE}}b|c{{PAGENAME}}d]]</nowiki> gives [[a{{NAMESPACE}}b|c{{PAGENAME}}d]]

==See also==
*[[Help:Template#Images_in_templates|Images in templates]].
*[[Help:Template#subst]] - on applying "subst" to a variable or to a template using a variable

{{h:f|langs=|enname={{PAGENAME}}}}
Root Admin, Bots, Bureaucrats, flow-bot, oversight, Administrators, Widget editors
24,656
edits

Navigation menu