User:AlanM1/Variables
Variables
From Help:Magic words#Variables. These all take an optional parameter to operate on a page other than the current one. Append an "E" for equivalents encoded for use in MediaWiki URLs (e.g {{PAGENAMEE}}, {{NAMESPACEE}}).
| Template | Result | Descrip |
|---|---|---|
| {{FULLPAGENAME}} | User:AlanM1/Variables | Page title including namespace |
| {{PAGENAME}} | AlanM1/Variables | Page title excluding namespace |
| {{BASEPAGENAME}} | AlanM1 | Page title excluding current subpage and namespace effectively the parent page without the namespace. |
| {{SUBPAGENAME}} | Variables | Subpage part of title |
| {{SUBJECTPAGENAME}} | User:AlanM1/Variables | Associated non-talk page |
| {{ARTICLEPAGENAME}} | User:AlanM1/Variables | |
| {{TALKPAGENAME}} | User talk:AlanM1/Variables | Associated talk page |
| {{NAMESPACE}} | User | Namespace of current page |
| {{SUBJECTSPACE}} | User | Associated non-talk namespace |
| {{ARTICLESPACE}} | User | |
| {{TALKSPACE}} | User talk | Associated talk namespace |
These do not take a parameter:
| Template | Result | Descrip |
|---|---|---|
| {{SITENAME}} | Wikipedia | Site name |
| {{SERVER}} | //en.wikipedia.org | Server |
| {{SERVERNAME}} | en.wikipedia.org | Server name |
| {{SCRIPTPATH}} | /w | Script path |
| {{CURRENTVERSION}} | 1.47.0-wmf.5 (86eebe7) | Current MediaWiki version |
| {{REVISIONID}} | - | Latest revision to current page |
| {{REVISIONDAY}} | 18 | Date, time, editor at last edit |
| {{REVISIONDAY2}} | 18 | |
| {{REVISIONMONTH}} | 05 | |
| {{REVISIONYEAR}} | 2026 | |
| {{REVISIONTIMESTAMP}} | 20260518153315 | |
| {{REVISIONUSER}} | Zinnober9 | |
| {{CURRENTYEAR}} | 2026 | Current date/time variables |
| {{CURRENTMONTH}} | 06 | |
| {{CURRENTMONTHNAME}} | June | |
| {{CURRENTMONTHABBREV}} | Jun | |
| {{CURRENTDAY}} | 9 | |
| {{CURRENTDAY2}} | 09 | |
| {{CURRENTDOW}} | 2 | |
| {{CURRENTDAYNAME}} | Tuesday | |
| {{CURRENTTIME}} | 06:32 | |
| {{CURRENTHOUR}} | 06 | |
| {{CURRENTWEEK}} | 24 | |
| {{CURRENTTIMESTAMP}} | 20260609063206 | |
| {{LOCALYEAR}} | 2026 | Site local date/time variables |
| {{LOCALMONTH}} | 06 | |
| {{LOCALMONTHNAME}} | June | |
| {{LOCALMONTHABBREV}} | Jun | |
| {{LOCALDAY}} | 9 | |
| {{LOCALDAY2}} | 09 | |
| {{LOCALDOW}} | 2 | |
| {{LOCALDAYNAME}} | Tuesday | |
| {{LOCALTIME}} | 06:32 | |
| {{LOCALHOUR}} | 06 | |
| {{LOCALWEEK}} | 24 | |
| {{LOCALTIMESTAMP}} | 20260609063206 | |
| {{NUMBEROFPAGES}} | 65,745,487 | Statistics on English Wikipedia Add |R to return numbers without commas
|
| {{NUMBEROFARTICLES}} | 7,193,063 | |
| {{NUMBEROFFILES}} | 969,477 | |
| {{NUMBEROFEDITS}} | 1,353,760,888 | |
| {{NUMBEROFUSERS}} | 53,192,951 | |
| {{NUMBEROFADMINS}} | 814 | |
| {{NUMBEROFACTIVEUSERS}} | 275,264 |
Parser functions
From Help:Magic words#Parser functions. These are fully documented at the Meta magic words page or ParserFunctions Extension documentation unless otherwise stated. {{{0}}} (arg0) is the arg after the colon, before the pipe before {{{1}}} (arg1).
Metadata
Add |R (i.e. {{{1}}}=R) to return numbers without commas.
| Template | Result | Descrip |
|---|---|---|
{{PAGEID}}
|
37960895 | Unique page identifier number |
{{PAGESIZE:User:AlanM1/Variables}}
|
13,323 | Size of page {{{0}}} in bytes
|
{{PROTECTIONLEVEL:edit}}
|
Protection level for action {{{0}}} on the current page
| |
{{PAGESINCATEGORY:Wikipedia features}}
|
93 | Number of pages in category {{{0}}}
|
{{NUMBERINGROUP:checkuser}}
|
46 | Number of users in group {{{0}}}
|
Formatting
| Template | Result | Descrip |
|---|---|---|
{{lc:STRING}}
|
string | Convert {{{0}}} to lower-case
|
{{lcfirst:STRING}}
|
sTRING | Convert first character of {{{0}}} to lower case
|
{{uc:string}}
|
STRING | Convert {{{0}}} to upper case
|
{{ucfirst:string}}
|
String | Convert first character of {{{0}}} to upper case
|
{{formatnum:1234567}}
|
1,234,567 | Format {{{0}}} with comma separators
|
{{formatnum:1,234,567|R}}
|
1234567 | Unformat {{{0}}} with comma separators
|
{{#formatdate:7 October 2012|default_format}}
|
October 7, 2012 | Formats date in {{{0}}} according to user's preference. If no preference set, {{{1}}} (default_format) (one of mdy, dmy, ymd, ISO 8601) is used.
|
{{padleft:string|8}}
|
00string | Pad {{{0}}} with zeros to the right or left; an alternative padding string can be given as {{{2}}}; the alternative padding string may be truncated if its length does not evenly divide by the required number of characters (i.e. the result is always {{{1}}} chars long)
|
{{padleft:string|8|/}}
|
//string | |
{{padright:string|8}}
|
string00 | |
{{padright:string|8|/}}
|
string// | |
{{plural:1|is|are}}
|
is | Returns {{{1}}} if {{{0}}} is 1, {{{2}}} if {{{0}}} is greater than 1
|
{{plural:3|is|are}}
|
are | |
{{#time:format_string|date_time_object}}
|
Format {{{1}}} date/time according to {{{0}}} format string (see mw:Help:Extension:ParserFunctions#.23time extension documentation page)
| |
{{#timel:format_string|date_time_object}}
|
Like #time, but for local time.
| |
{{gender:username|masculine|female|neutral}}
|
neutral | Produces alternative text according to the gender specified by the given user in his/her preferences |
{{#tag:tagname|content}}
|
<tagname ''parameter1''="'value1'" ''parameter2''="'value2'"> content </tagname> | Equivalent to an HTML tag or pair of tags; can be used for nesting references |
Paths
| Template | Result | Descrip |
|---|---|---|
{{localurl:AlanM1/Variables}}{{localurl:AlanM1/Variables|query string}}
|
/wiki/AlanM1/Variables /w/index.php?title=AlanM1/Variables&query string |
Relative path to the title |
{{fullurl:AlanM1/Variables}}{{fullurl:AlanM1/Variables|query_string}}
|
//en.wikipedia.org/wiki/AlanM1/Variables //en.wikipedia.org/w/index.php?title=AlanM1/Variables&query_string |
Absolute path to the title, without a protocol prefix |
{{canonicalurl:AlanM1/Variables}}{{canonicalurl:AlanM1/Variables|query_string}}
|
https://en.wikipedia.org/wiki/AlanM1/Variables https://en.wikipedia.org/w/index.php?title=AlanM1/Variables&query_string |
Absolute path to the title, with a protocol prefix |
{{filepath:file name}}
|
Absolute URL to a media file | |
{{urlencode:string}}
|
string | Input encoded for use in URLs |
{{anchorencode:string}}
|
string | Input encoded for use in URL section anchors |
{{ns:n}}{{nse:n}}
|
{{ns:n}} {{nse:n}} |
Name for the namespace with index n; use for the equivalent encoded for MediaWiki URLs |
{{#rel2abs:path}}
|
path | Converts a relative file path to absolute; see the extension documentation |
{{#titleparts:pagename|number of segments to return|first segment to return}}
|
Pagename | Splits title into parts; see the extension documentation |
Conditional expressions
These are covered at the extension documentation page. Some parameters are optional.
| Template | Result | Descrip |
|---|---|---|
{{#expr: expression}}
|
Expression error: Unrecognized punctuation character "'". | Evaluates the given expression; see Help:Calculation |
{{#if: test string|value if non-empty|value if empty}}
|
value if non-empty | Selects one of two values based on whether the test string is empty |
{{#ifeq: string 1|string 2|value if equal|value if unequal}}
|
value if unequal | Selects one of two values based on whether the test strings are equal – numerically if applicable |
{{#iferror: test string|value if error|value if correct}}
|
value if correct | Selects value based on whether the test string generates a parser error |
{{#ifexpr: expression|value if true|value if false}}
|
Expression error: Unrecognized punctuation character "'". | Selects value based on evaluation of expression |
{{#ifexist: page title|value if exists|value if doesn't exist}}
|
value if doesn't exist | Selects value depending on whether a page title exists |
{{#switch: test|...|default}}
|
default | Provides alternatives based on the value of the test string |
Note that with #if: expressions, a variable like {{{1}}} always requires a final pipe: . If it is absent, then whenever the parameter 1 is absent, instead of leaving the field blank the software will use the actual text {{{1}}} and the field will never be empty.
For the use of these functions in tables, see Conditional tables.
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.