Help:Variable

From lensowiki
Jump to: navigation, search

  A variable can be considered a predefined template.

This is a list of variables that can be used in the wikitext. The way they are rendered vary with time (directly depending on time, or e.g. for number of articles, depending on the creation of other articles), on the project (it changes when the wikitext is copied), or on the page in which it occurs (it changes when the wikitext is copied, when the page is renamed, and when the page is included in another page).

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 "magic words" the system uses.

Constants depending on parameters

Most of the following "constants" are in fact colon functions also known as predefined templates, and might change, e.g. if the {{SERVERNAME}} is changed. They are listed here for historical reasons:

{{ns:-2}} {{ns:Media}} Media Media
{{ns:-1}} {{ns:Special}} Special Special
{{ns:0}}   ( main namespace ) ( empty string )
{{ns:1}}  {{ns:Talk}} Talk Talk
{{ns:2}}  {{ns:User}} User User
{{ns:3}}  {{ns:User_talk}} User talk User talk
{{ns:4}}  {{ns:Project}} lensowiki lensowiki
{{ns:5}}  {{ns:Project_talk}} lensowiki talk lensowiki talk
{{ns:6}}  {{ns:Image}} File File
{{ns:7}}  {{ns:Image_talk}} File talk File talk
{{ns:8}}  {{ns:MediaWiki}} MediaWiki MediaWiki
{{ns:9}} {{ns:MediaWiki_talk}} MediaWiki talk MediaWiki talk
{{ns:10}} {{ns:Template}} Template Template
{{ns:11}} {{ns:Template_talk}} Template talk Template talk
{{ns:12}} {{ns:Help}} Help Help
{{ns:13}} {{ns:Help_talk}} Help talk Help talk
{{ns:14}} {{ns:Category}} Category Category
{{ns:15}} {{ns:Category_talk}} Category talk Category talk
{{ns:100}} {{ns:102}}, etc. (customized )
{{ns:101}} {{ns:103}}, etc.
{{SITENAME}} lensowiki
{{SERVER}} http://www.lensovet.net
{{SERVERNAME}} www.lensovet.net
{{localurl:fullpagename}} /~sysadmin/w/Fullpagename
{{localurl:page|query=x}} /~sysadmin/w/index.php?title=Page&query=x
{{localurl:a&b!}}
{{localurle:a&b!}}
{{localurl:a&b!}}
{{localurle:a&b!}}
{{urlencode:a&b!}} a%26b%21
{{fullurl:fullpagename}} http://www.lensovet.net/~sysadmin/w/Fullpagename
{{fullurl:a&b!|u=v}}  {{fullurl:a&b!|u=v}}
{{fullurle:a&b!|u=v}} {{fullurle:a&b!|u=v}}

The colon function localurl: replaces spaces by underscores and special characters by escape codes, e.g. {{localurl:a !}} gives /~sysadmin/w/A_!. The main purpose was to create a link to a given page in external link style in the same project or a project which uses the same string in the URL between the server name and the page name. This function is now better served by less verbose fullurl: constructs, {{fullurl:page}} is a shorthand for {{SERVER}}{{localurl:page}}.

Both fullurle: and localurle: performed additional character escaping on the resulting link, but no example is known where that still has any additional effect.

Note that fullurl: and localurl: don't encode special characters and spaces in the optional query-string parameter. At least for spaces this will result in broken URLs:
{{fullurl:m:Special:Contributions|target=Jimbo Wales&limit=10}}
http://meta.wikimedia.org/wiki/Special:Contributions?target=Jimbo Wales&limit=10

With target={{urlencode:Jimbo Wales}}&limit=10 as query-string it works:
http://meta.wikimedia.org/wiki/Special:Contributions?target=Jimbo+Wales&limit=10

The new urlencode: encodes spaces as "+", not "_" or the generally supported "%20", this might have interesting effects, take care. Trailing spaces are stripped, leading spaces respected: {{urlencode:  @ !  }} yields %40+%21.

For obvious reasons encoding "}}" or "|" cannot work directly. Don't encode "=", "&", or ";" in structured query-strings unless you really want it.

Depending on page

{{PAGENAME}} Variable {{PAGENAMEE}} Variable
{{NAMESPACE}} Help {{NAMESPACEE}} Help
{{FULLPAGENAME}} Help:Variable {{FULLPAGENAMEE}} Help:Variable
    {{REVISIONID}} 1941
{{TALKSPACE}} Help talk {{SUBJECTSPACE}} Help
{{TALKSPACEE}} Help_talk {{SUBJECTSPACEE}} Help
{{TALKPAGENAME}} Help talk:Variable {{SUBJECTPAGENAME}} Help:Variable
{{TALKPAGENAMEE}} Help_talk:Variable {{SUBJECTPAGENAMEE}} Help:Variable
{{ARTICLESPACE}} Help {{ARTICLEPAGENAME}} Help:Variable
{{ARTICLESPACEE}} Help {{ARTICLEPAGENAMEE}} Help:Variable
{{BASEPAGENAME}} Variable {{SUBPAGENAME}} Variable
{{BASEPAGENAMEE}} Variable {{SUBPAGENAMEE}} Variable

For the rendering on page A, these variables depend on page A, even if page A contains the variable due to inclusion of page B. Variables in the sort key of a category tag refer to the page with the tag, not the category page where it takes effect.

{{NAMESPACE}} and {{NAMESPACEE}} return an empty string in the article namespace {{ns:0}}, see above and NS:0.

PAGENAMEE displays the page title in the form that is used in URLs, i.e. with underscores for spaces, and percent-encoding for special characters, and is therefore used for constructing URLs incl. query strings.

For example, on Template talk:!, SUBJECTPAGENAMEE would produce Template:%21. Don't encode PAGENAMEE etc. again, i.e. don't use it in the first parameter of fullurl: and similar colon functions, {{urlencode:%21}} = %2521 probably won't work as expected. Query strings  in PURL redirections are an exception.

The "EE" encoding examples shown above for this page are not very interesting, only TALKPAGENAMEE and TALKSPACEE differ from TALKPAGENAME and TALKSPACE. See Help:Link and Help:Magic words for other examples.

In a subpage, [[../]] renders as a link to the parent page. For example, on m:Link/a/b it gives an internal link to m:Link/a, see Help:Link#Subpage feature.

Template:Evaldemo showing the current unique revision number of a saved page as used for diffs in the page history is in essence useless, it can't be substituted and also doesn't work in preview.

Varying with time

{{CURRENTYEAR}} 2024   {{CURRENTMONTH}} 12
{{CURRENTMONTHNAME}} December   {{CURRENTMONTHABBREV}} Dec
{{CURRENTMONTHNAMEGEN}} December   {{CURRENTWEEK}} 52
{{CURRENTDAY}} 23   {{CURRENTDAY2}} 23
{{CURRENTDAYNAME}} Monday   {{CURRENTDOW}} 1
{{CURRENTTIME}} 02:05   {{CURRENTVERSION}} 1.31.16 (7ab9dfd)
{{CURRENTTIMESTAMP}} 20241223020529
{{NUMBEROFADMINS}} 1   {{NUMBEROFADMINS:R}} 1
{{NUMBEROFARTICLES}} 235   {{NUMBEROFARTICLES:R}} 235
{{NUMBEROFFILES}} 54   {{NUMBEROFFILES:R}} 54
{{NUMBEROFPAGES}} 954   {{NUMBEROFPAGES:R}} 954
{{NUMBEROFUSERS}} 10   {{NUMBEROFUSERS:R}} 10

Time variables which change more often than once a day are generally useful only as curiosities. Because of the way article HTML is cached, these variables may be wrong by up to 24 hours, and so are not a reliable way to tell the user the current time.

Please note that a template using more than one CURRENT variable directly or indirectly is suspicious. There can be critical races near hh:mm:59. The following code to determine the minute can produce spurious results if the timestamp changes during the evaluation: {{#expr:(( {{CURRENTTIMESTAMP}}-{{CURRENTTIMESTAMP}} mod 100)/100) mod 100}} = 5
This is actually an intermittent bug with MOD depending on the size (not the value) of CURRENTTIMESTAMP, see template:CURRENTMINUTE ( talk edit history links ).

CURRENTDOW 
0=Sunday, 1=Monday, .. 6=Saturday.
CURRENTWEEK 
is the number of the current week (1-53) according to ISO 8601 with no leading zero.
CURRENTDAY2 
adds a leading zero to days 1...9, this allows to construct the ISO date formats like 2024-12-23T02:05Z.
CURRENTMONTHNAMEGEN 
is the genitive grammatical form of the month name (used in Finnish Template:Unclear).
NUMBEROFARTICLES 
see Help:Article count and Special:Statistics..

Substitution

Main article: Help:Substitution

When {{<includeonly>subst:</includeonly>CURRENTTIMESTAMP}} is included and thereby substituted, the timestamp of doing that is put in the wikitext, and similarly for other variables. Examples:

{{CURRENTTIMESTAMP}}
20241223020529 - stays a variable on pages including the template
{{subst:CURRENTTIMESTAMP}}
20060526024210 - became a substituted constant in the template
{{<includeonly>subst:</includeonly>CURRENTTIMESTAMP}}
20241223020529 - becomes a constant at the time of its inclusion

New NUMBEROF syntax

The "old" (for some weeks) syntax was {{ NUMBEROFitem|R }} to get the "raw" number without fancy comma separators. The new syntax is {{ NUMBEROFitem:R }} with a colon to get the "raw" number of whatever. This also affects the new magic words PAGESINNS and PAGESINNAMESPACE, now disabled by default.

Using the old format will (try to) include a corresponding template. Because the "old" feature is in fact rather new it might be possible to fix the syntax using What links here:
NUMBEROF ADMINS, ARTICLES, FILES, PAGES, USERS.
PAGESINNS 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 100, 101, 102, 103, etc.

Examples of combinations

{{fullurl:{{FULLPAGENAME}}|action=edit}}
http://www.lensovet.net/~sysadmin/w/index.php?title=Help:Variable&action=edit
 
{{fullurl:w:en:Special:Whatlinkshere|target={{NAMESPACE}}:Contents}}
http://en.wikipedia.org/wiki/en:Special:Whatlinkshere?target=Help:Contents
 
{{fullurl:m:Special:Whatlinkshere|target={{FULLPAGENAME}}}}
http://meta.wikimedia.org/wiki/Special:Whatlinkshere?target=Help:Variable
 
{{fullurl:{{FULLPAGENAME}}|action=edit}}
http://www.lensovet.net/~sysadmin/w/index.php?title=Help:Variable&action=edit
 
[[{{NAMESPACE}} talk:{{PAGENAME}}]]
Help talk:Variable
 
{{fullurl:{{NAMESPACE}} talk:{{PAGENAME}}}}
http://www.lensovet.net/~sysadmin/w/Help_talk:Variable
 

The old form {{SERVER}}{{localurl:page }} is in essence the same as {{fullurl:page }} in recent (1.5+) versions of the software.

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.


Variable in the form of a template call

If the syntax of a template call with parameters is applied with the name of a variable, depending on the variable the parameters are either ignored or cause the variable to be interpreted as a (non-existing) template:

  1. Variables like {{NUMBEROFPAGES:R}} = 954 with a "raw" format are always handled as variable, {{NUMBEROFPAGES:R|Para|meter}} = 954.
  2. Other variables like {{CURRENTDAYNAME}} = Monday are handled as template for given parameter(s), {{CURRENTDAYNAME|x}} = Template:CURRENTDAYNAME.
  3. Colon functions like {{lc: Lower Case}} = lower case ignore extraneous parameters, {{lc: Lower|Case}} = lower.
  4. Colon function ns (e.g. {{ns: 1}} = Talk) gives an empty string for a non-applicable numerical parameter value, and evaluates a non-numerical parameter value as template, even if it has the name of a variable:
    {{ns: 1234}} =
    {{ns: t|abc}} = Template:Ns: t
    {{ns: CURRENTDAYNAME}} = Template:Ns: CURRENTDAYNAME.
  5. Colon functions like fullurl don't support the ../ notation, and in namespaces supporting subpages this has odd effects: like above, they evaluate such an invalid parameter value as template, see Link/a and Link/a/b. Here it just renders the wikitext:
    {{fullurl:../a}} = Template:Fullurl:../a.
    The cases #2, #4, and #5 resulting in template calls are probably related.

See also

http://www.fayeunrauphotography.com/ kjøp cialis 520853 http://www.primetermites.com/ ジェネリックバイアグラ 5575 http://www.witch-ring.com/Generic-Viagra/ Comprando viagra sfnjy http://www.flweaver.com/ online Cialis kmt http://www.blogdemoteros.com/ tadalafil 5271