Difference between revisions of "Help:Magic words"

From Gunsopedia
Jump to: navigation, search
(General information)
(See also)
 
(7 intermediate revisions by one user not shown)
Line 21: Line 21:
  
 
== Behavior switches ==
 
== Behavior switches ==
{{Hatnote|For documentation, see the [[mw:Help:Magic words#Behavior switches|Behavior switches]] section of the MediaWiki page, unless otherwise stated.}}
+
: ''For documentation, see the [[mw:Help:Magic words#Behavior switches|Behavior switches]] section of the MediaWiki page, unless otherwise stated.''
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 37: Line 37:
 
|-
 
|-
 
  | <code><nowiki> __NOEDITSECTION__ </nowiki></code>
 
  | <code><nowiki> __NOEDITSECTION__ </nowiki></code>
  | Hides the "edit" links normally beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using e.g. an [[HTML element|HTML tag]] such as {{tag|h2|content=[Heading]}} rather than with the usual wiki equals-signs syntax (e.g. {{nowrap|1=<code>== [Heading] ==</code>}}{{thinsp}}).
+
  | Hides the "edit" links normally beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using e.g. an HTML tag such as '''<nowiki><h2>[Heading]</h2></nowiki>''' rather than with the usual wiki equals-signs syntax (e.g. '''== [Heading] ==''').
 
|-
 
|-
 
  | <code><nowiki> __NEWSECTIONLINK__ </nowiki></code>
 
  | <code><nowiki> __NEWSECTIONLINK__ </nowiki></code>
Line 49: Line 49:
 
|-
 
|-
 
  | <code><nowiki> __HIDDENCAT__ </nowiki></code>
 
  | <code><nowiki> __HIDDENCAT__ </nowiki></code>
  | Makes a category [[WP:HIDDENCAT|hidden]] when included on that category's page.
+
  | Makes a category [[Categorization#Hiding_categories|hidden]] when included on that category's page.
 
|-
 
|-
 
  | <code><nowiki> __INDEX__ </nowiki></code>
 
  | <code><nowiki> __INDEX__ </nowiki></code>
  | Instructs [[Web search engine|search engine]]s to index the page.
+
  | Instructs search engines to index the page.
 
|-
 
|-
 
  | <code><nowiki> __NOINDEX__ </nowiki></code>
 
  | <code><nowiki> __NOINDEX__ </nowiki></code>
Line 61: Line 61:
 
|-
 
|-
 
  | <code><nowiki> __DISAMBIG__ </nowiki></code>
 
  | <code><nowiki> __DISAMBIG__ </nowiki></code>
  | Marks a page as a [[WP:DAB|disambiguation page]], adds it to [[Special:DisambiguationPages]] and places inward links in [[Special:DisambiguationPageLinks]]. (See [[mw:Extension:Disambiguator]].)
+
  | Marks a page as a [[help:disambiguation|disambiguation page]], adds it to [[Special:DisambiguationPages]] and places inward links in [[Special:DisambiguationPageLinks]]. (See [[mw:Extension:Disambiguator]].)
 
|-
 
|-
  | {{wikivar|DISPLAYTITLE|''title''}}
+
  | <code><nowiki>{{DEFAULTSORT:</nowiki></code>''sortkey''<code><nowiki>}}</nowiki></code>
| Used to amend the [[WP:DISPLAYTITLE|displayed form]] of the page's title.
+
  | Sets the default sort key (the index) under which the page is categorised.
|-
+
| {{wikivar|DEFAULTSORT|''sortkey''}}
+
  | Sets the default [[WP:SORTKEY|key]] (the index) under which the page is categorised.
+
|-
+
| {{wikivar|NOEXTERNALLANGLINKS}}
+
| (equivalent to {{wikivar|NOEXTERNALLANGLINKS|*}}{{thinsp}}) Suppresses the automated inclusion of [[Wikidata:Help:Linking Wikipedia pages|Wikidata]] [[Help:Interlanguage links|interlanguage links]] on the lefthand side of the page. Links to particular rather than all languages may be suppressed by using {{wikivar|NOEXTERNALLANGLINKS|''list''}}, where ''list'' a [[Vertical bar|pipe]]-[[Delimiter|delimited]] list of [[language code]]s (e.g. {{wikivar|NOEXTERNALLANGLINKS|fr{{pipe}}es{{pipe}}ja}} to suppress the French ("fr"), Spanish ("es") and Japanese ("ja") interlanguage links). (See [[mw:Extension:Wikibase Client#noexternallanglinks]].)
+
 
|}
 
|}
  
 
== Variables ==
 
== Variables ==
{{Shortcut|WP:VAR}}
+
: ''For more documentation, see [[mw:Help:Magic words#Variables|this Wikipedia page]].
{{about|the MediaWiki variables used in Wikipedia|more documentation|mw:Help:Magic words#Variables}}
+
  
 
The example outputs in the following table are those that would be produced on the page "{{FULLPAGENAME}}/subpage".
 
The example outputs in the following table are those that would be produced on the page "{{FULLPAGENAME}}/subpage".
Line 103: Line 96:
 
  | {{BASEPAGENAME:{{FULLPAGENAME}}/subpage}}
 
  | {{BASEPAGENAME:{{FULLPAGENAME}}/subpage}}
 
  | Current page's name excluding namespace and any subpage element or elements (i.e. the first forward-slash ("/") and anything following; in effect, a subpage's parent's name less its namespace).
 
  | Current page's name excluding namespace and any subpage element or elements (i.e. the first forward-slash ("/") and anything following; in effect, a subpage's parent's name less its namespace).
|-
 
| {{wikivar|ROOTPAGENAME}}
 
| {{ROOTPAGENAME:{{FULLPAGENAME}}/subpage}}
 
| Name of the root of the current page. Would return Foo on page Help:Foo/Bar/Baz
 
 
|-
 
|-
 
  | {{wikivar|SUBPAGENAME}}
 
  | {{wikivar|SUBPAGENAME}}
Line 128: Line 117:
 
  | Associated talk page's namespace.
 
  | Associated talk page's namespace.
 
|-
 
|-
  | {{longitem|line-height:1.5em|{{wikivar|FULLPAGENAMEE}},<br/>{{wikivar|PAGENAMEE}},<br/>{{pad|0.4em}}(etc.)}}
+
  | {{wikivar|FULLPAGENAMEE}},<br/>{{wikivar|PAGENAMEE}},<br/>&nbsp;&nbsp;&nbsp;(etc.)
  | {{longitem|line-height:1.5em|{{FULLPAGENAMEE:{{FULLPAGENAME}}/subpage}},<br/>{{PAGENAMEE:{{FULLPAGENAME}}/subpage}},<br/>(etc.)}}
+
  | {{FULLPAGENAMEE:{{FULLPAGENAME}}/subpage}},<br/>{{PAGENAMEE:{{FULLPAGENAME}}/subpage}},<br/>(etc.)
  | Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki [[URL]]s (i.e. with underscores replacing spaces).
+
  | Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki URLs (i.e. with underscores replacing spaces).
 
|}<!--
 
|}<!--
  
-->''Note:'' The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon ({{thinsp|''':'''}}) is used to pass the parameter, rather than a pipe ({{thinsp|'''&#124;'''}}) that is used in templates, like <code><nowiki>{{MAGICWORD:value}}</nowiki></code>. For example, <code><nowiki>{{TALKPAGENAME:Wikipedia:MOS}}</nowiki></code> returns <code><nowiki>Wikipedia talk:MOS</nowiki></code> on any page. See [[meta:Help:Page name]] for more details of parser functions.
+
-->''Note:'' The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon (''':''') is used to pass the parameter, rather than a pipe ('''&#124;''') that is used in templates, like <code><nowiki>{{MAGICWORD:value}}</nowiki></code>. For example, <code><nowiki>{{TALKPAGENAME:Wikipedia:MOS}}</nowiki></code> returns <code><nowiki>Wikipedia talk:MOS</nowiki></code> on any page. See [https://meta.wikimedia.org/wiki/Help:Page_name meta:Help:Page name] for more details of parser functions.
  
 
{| class=wikitable
 
{| class=wikitable
Line 143: Line 132:
 
|-
 
|-
 
  | {{wikivar|SERVERNAME}}    || {{SERVERNAME}}    ||
 
  | {{wikivar|SERVERNAME}}    || {{SERVERNAME}}    ||
|-
 
| {{wikivar|SCRIPTPATH}}    || {{SCRIPTPATH}}    ||
 
 
|-
 
|-
 
  | {{wikivar|CURRENTVERSION}} || {{CURRENTVERSION}} || Returns current MediaWiki version.
 
  | {{wikivar|CURRENTVERSION}} || {{CURRENTVERSION}} || Returns current MediaWiki version.
Line 153: Line 140:
 
! Date and time
 
! Date and time
 
! Revision data
 
! Revision data
! Statistics{{sup|b}}
+
! Statistics
 
|- style="vertical-align:top"
 
|- style="vertical-align:top"
 
|
 
|
 
{|
 
{|
 
| ''Universal time''
 
| ''Universal time''
{{startplainlist}}
 
 
* {{wikivar|CURRENTYEAR}}
 
* {{wikivar|CURRENTYEAR}}
 
* {{wikivar|CURRENTMONTH}}
 
* {{wikivar|CURRENTMONTH}}
Line 171: Line 157:
 
* {{wikivar|CURRENTWEEK}}
 
* {{wikivar|CURRENTWEEK}}
 
* {{wikivar|CURRENTTIMESTAMP}}
 
* {{wikivar|CURRENTTIMESTAMP}}
{{endplainlist}}
 
 
| ''Local website time''
 
| ''Local website time''
{{startplainlist}}
 
 
* {{wikivar|LOCALYEAR}}
 
* {{wikivar|LOCALYEAR}}
 
* {{wikivar|LOCALMONTH}}
 
* {{wikivar|LOCALMONTH}}
Line 186: Line 170:
 
* {{wikivar|LOCALWEEK}}
 
* {{wikivar|LOCALWEEK}}
 
* {{wikivar|LOCALTIMESTAMP}}
 
* {{wikivar|LOCALTIMESTAMP}}
{{endplainlist}}
 
 
|}
 
|}
|{{startplainlist}}
+
|
* {{wikivar|REVISIONID}}{{sup|a}}
+
* {{wikivar|REVISIONID}}<sup>a</sup>
 
* {{wikivar|REVISIONDAY}}
 
* {{wikivar|REVISIONDAY}}
 
* {{wikivar|REVISIONDAY2}}
 
* {{wikivar|REVISIONDAY2}}
Line 196: Line 179:
 
* {{wikivar|REVISIONTIMESTAMP}}
 
* {{wikivar|REVISIONTIMESTAMP}}
 
* {{wikivar|REVISIONUSER}}
 
* {{wikivar|REVISIONUSER}}
|{{startplainlist}}
+
|
 
* {{wikivar|NUMBEROFPAGES}}
 
* {{wikivar|NUMBEROFPAGES}}
 
* {{wikivar|NUMBEROFARTICLES}}
 
* {{wikivar|NUMBEROFARTICLES}}
Line 205: Line 188:
 
* {{wikivar|NUMBEROFADMINS}}
 
* {{wikivar|NUMBEROFADMINS}}
 
* {{wikivar|NUMBEROFACTIVEUSERS}}
 
* {{wikivar|NUMBEROFACTIVEUSERS}}
{{endplainlist}}
 
 
|}
 
|}
{{nowrap|{{sup|a}} {{wikivar|REVISIONID}} cannot be [[Wikipedia:Substitution|substituted]] and does not function in preview.<br/>{{sup|b}} English Wikipedia.}}
+
<sup>a</sup> {{wikivar|REVISIONID}} cannot be [[help:Substitution|substituted]] and does not function in preview.
  
 
== Parser functions ==
 
== Parser functions ==
{{Shortcut|WP:PF}}
+
: ''For documentation, see the [[mw:Help:Magic words|MediaWiki magic words page]] or the [[mw:Help:Extension:ParserFunctions|ParserFunctions Extension page]], unless otherwise stated.
{{Hatnote|For documentation, see the [[mw:Help:Magic words|MediaWiki magic words page]] or the [[mw:Help:Extension:ParserFunctions|ParserFunctions Extension page]], unless otherwise stated.}}
+
  
 
===Metadata===
 
===Metadata===
Line 224: Line 205:
 
  | Size of page named ''pagename'' in bytes.
 
  | Size of page named ''pagename'' in bytes.
 
|-
 
|-
| {{anchor|PROTECTIONLEVEL}}{{wikivar|PROTECTIONLEVEL|''action''{{pipe}}''pagename''}}
+
| {{wikivar|PROTECTIONLEVEL|''action''{{pipe}}''pagename''}}
| [[Wikipedia:Protection policy|Protection level]] assigned to ''action'' ("edit", "move", etc) on page named ''pagename''.
+
| [[gunsopedia:Protection policy|Protection level]] assigned to ''action'' ("edit", "move", etc) on page named ''pagename''.
 
|-
 
|-
 
  | {{wikivar|PENDINGCHANGELEVEL}}
 
  | {{wikivar|PENDINGCHANGELEVEL}}
  | Protection level for [[WP:PC|pending changes]] on the current page.
+
  | Protection level for [[gunsopedia:Pending changes|pending changes]] on the current page.
 
|-
 
|-
 
  | {{wikivar|PAGESINCATEGORY|''categoryname''}}
 
  | {{wikivar|PAGESINCATEGORY|''categoryname''}}
Line 236: Line 217:
 
  | Number of users in the [[Help:User rights|usergroup]] named ''groupname''.
 
  | Number of users in the [[Help:User rights|usergroup]] named ''groupname''.
 
|}
 
|}
To output numbers without comma [[Delimiter|separator]]s (for example, as "123456789" rather than "123,456,789"), append the parameter <code>|R</code>.
+
To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter <code>|R</code>.
  
 
===Formatting===
 
===Formatting===
Line 267: Line 248:
 
  | Outputs ''singular'' if ''N'' is equal to 1, otherwise outputs ''plural''. See the [[mw:Help:Magic words#Localization|documentation at mediawiki.org]] for more details.
 
  | Outputs ''singular'' if ''N'' is equal to 1, otherwise outputs ''plural''. See the [[mw:Help:Magic words#Localization|documentation at mediawiki.org]] for more details.
 
|-
 
|-
  | <code> {{((}}#time:''format''{{pipe}}''object''{{))}} </code><br/><code> {{braces|#timel:}} </code> {{smaller|(for local time)}}
+
  | <code> {{((}}#time:''format''{{pipe}}''object''{{))}} </code><br/><code> {{braces|#timel:}} </code> (for local time)
  | Used to format dates and times. <code>#timel</code> is based on local time as defined for the entire wiki; for the English Wikipedia, where local time is set to [[Coordinated Universal Time|UTC]], this is identical to <code>#time</code>. (See [[mw:Help:Extension:ParserFunctions##time]].)
+
  | Used to format dates and times. <code>#timel</code> is based on local time as defined for the entire wiki; for the English Wikipedia, where local time is set to UTC, this is identical to <code>#time</code>. (See [[mw:Help:Extension:ParserFunctions##time]].)
 
|-
 
|-
 
  | <code> {{((}}gender:''user'' {{pipe}}''m_out'' {{pipe}}''f_out'' {{pipe}}''u_out''{{))}} </code>
 
  | <code> {{((}}gender:''user'' {{pipe}}''m_out'' {{pipe}}''f_out'' {{pipe}}''u_out''{{))}} </code>
  | Outputs ''m_out'', ''f_out'' or ''u_out'' according to whether the gender specified in ''user''{{thinsp}}'s preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see [[mw:Help:Magic words#gender]] and [[translatewiki:Special:MyLanguage/Gender|translatewiki:Gender]].
+
  | Outputs ''m_out'', ''f_out'' or ''u_out'' according to whether the gender specified in user's preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see [[mw:Help:Magic words#gender]].
 
|-
 
|-
 
  | <code> {{((}}#tag:''tag''{{pipe}}''content'' {{pipe}}''p1''=''v1'' {{pipe}}''p2''=''v2''{{))}} </code>
 
  | <code> {{((}}#tag:''tag''{{pipe}}''content'' {{pipe}}''p1''=''v1'' {{pipe}}''p2''=''v2''{{))}} </code>
  | An equivalent to the HTML <code>&lt;''tag''>...&lt;/''tag''><code> that is useful when e.g. [[WP:REFNEST|nesting references]].
+
  | An equivalent to the HTML <code>&lt;''tag''>...&lt;/''tag''><code> that is useful when e.g. [[wikipedia:WP:REFNEST|nesting references]].
 
|}
 
|}
  
Line 311: Line 292:
  
 
===Conditional===
 
===Conditional===
{{hatnote|Some parameters are optional. For documentation, see [[mw:Help:Extension:ParserFunctions]]. For #switch specifically, see [[Help:Switch parser function]].}}
+
: ''Some parameters are optional. For documentation, see [[mw:Help:Extension:ParserFunctions]]. For #switch specifically, see [[Wikipedia:Help:Switch parser function]].
 +
 
 
{| class="wikitable"
 
{| class="wikitable"
 
! Code
 
! Code
Line 317: Line 299:
 
|-
 
|-
 
  |<code> {{((}}#expr:''expression''{{))}} </code>
 
  |<code> {{((}}#expr:''expression''{{))}} </code>
  | Evaluates ''expression'' (see [[m:Help:Calculation]]).
+
  | Evaluates ''expression'' (see [https://meta.wikimedia.org/wiki/Help:Calculation m:Help:Calculation]).
 
|-
 
|-
 
  | <code> {{((}}#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </code>
 
  | <code> {{((}}#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </code>
  | Outputs ''result2'' if ''string'' is [[Empty string|empty]], otherwise outputs ''result1''.
+
  | Outputs ''result2'' if ''string'' is empty, otherwise outputs ''result1''.
 
|-
 
|-
 
  | <code> {{((}}#ifeq:''string1''{{pipe}}''string2'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </code>
 
  | <code> {{((}}#ifeq:''string1''{{pipe}}''string2'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </code>
Line 338: Line 320:
 
|}
 
|}
  
If, in these conditional functions, [[Empty string|empty]] unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. <code>{{(((}}1{{pipe}}{{)))}}</code>, <code>{{(((}}2{{pipe}}{{)))}}</code>, etc., rather than <code>{{(((}}1{{)))}}</code>, <code>{{(((}}2{{)))}}</code>, etc.).
+
If, in these conditional functions, empty unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. <code>{{{1{{pipe}}}}}</code>, <code>{{{2{{pipe}}}}}</code>, etc., rather than <code>{{{1}}}</code>, <code>{{{2}}}</code>, etc.).
 
* For the use of these functions in tables, see [[Wikipedia:Conditional tables]].
 
* For the use of these functions in tables, see [[Wikipedia:Conditional tables]].
* For examples and further explanations, see [[Help:Conditional expressions]] and [[Help:Switch parser function]].
+
* For examples and further explanations, see [[Wikipedia:Help:Conditional expressions]] and [[Wikipedia:Help:Switch parser function]].
  
 
===Other===
 
===Other===
{| class="wikitable"
 
! Code
 
! Notes
 
|-
 
| <code> {{((}}#babel:''code1''{{pipe}}''code2''{{pipe}}...{{))}} </code>
 
| {{tl|Babel}} template replacement (see [[mw:Extension:Babel#Usage|Extension:Babel]]).
 
|-
 
| <code> {{((}}#coordinates:''arg1''{{pipe}}''arg2''{{pipe}}...{{))}} </code>
 
| GeoData coordinates function (see [[mw:Extension:GeoData|Extension:GeoData]]).
 
|-
 
| <code> {{((}}#invoke:''mod''{{pipe}}''func'' {{pipe}}''arg1'' {{pipe}}''arg2'' {{pipe}}...{{))}} </code>
 
| Calls the function ''func'' within the [[mw:Extension:Scribunto|Scribunto]] module ''mod''. (See [[Wikipedia:Lua]].)
 
|-
 
| <code> {{((}}#language:''code1''{{pipe}}''code2''{{))}} </code>
 
| Outputs the name of the language identified by the [[language code]] ''code1'' in the language identified by ''code2''. If ''code2'' is not supplied, the name of the language identified by ''code1'' will be output in that language. For example, "<code>{{braces|#language:ar}}</code>" outputs "{{thinsp|{{#language:ar}}}}" while "<code>{{braces|#language:ar{{pipe}}en}}</code>" and "<code>{{braces|#language:ar{{pipe}}fr}}</code>" output, respectively, "{{#language:ar|en}}" and "{{#language:ar|fr}}". (See [[mw:Help:Magic words#Miscellaneous]].)
 
|-
 
| <code> {{((}}#property:''arg1''{{pipe}}''arg2''{{pipe}}...{{))}} </code>
 
| (See [[m:Wikidata/Notes/Inclusion syntax v0.4]].)
 
|-
 
| <code> {{((}}#target:''noticeboard''{{))}} </code>
 
| MassMessage function (see [[m:MassMessage]] and [[mw:Help:Extension:MassMessage]]).
 
|-
 
| <code> {{((}}int:''messagename''{{))}} </code>
 
| [[Wikipedia:Transclusion|Transcludes]] a page (such as a system message) in [[Help:MediaWiki namespace|MediaWiki namespace]] according to the user's language preferences.
 
|}
 
  
 
== See also ==
 
== See also ==
Line 373: Line 330:
 
* [[mw:Manual:Extending wiki markup]]
 
* [[mw:Manual:Extending wiki markup]]
 
* [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/parser/CoreParserFunctions.php?view=log CoreParserFunctions.php]
 
* [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/parser/CoreParserFunctions.php?view=log CoreParserFunctions.php]
* [[User:Cacycle/wikEd|wikEd]], a MediaWiki editor with syntax highlighting for templates and parser functions
+
* [[wikipedia:User:Cacycle/wikEd|wikEd]], a MediaWiki editor with syntax highlighting for templates and parser functions
* {{myprefs|9|Editing|check=Syntax highlighter}}
+
 
+
{{Gunsopedia technical help|collapsed}}
+
  
 
[[Category:help pages]]
 
[[Category:help pages]]

Latest revision as of 14:36, 28 June 2015

See also: Help:Magic words for beginners

Contents

Magic words (which include parser functions, variables and behavior switches) are features of wiki markup that enable various instructions to be given to the MediaWiki software. For example, the magic words may be used to suppress or position the table of contents, or to produce other variable outputs, as is often required in templates.

A quick reference for magic words can be found on this page. For more complete documentation, see the following pages on the MediaWiki site:

[edit] General information

There are three types of magic words:

  1. Behavior switches: uppercase words surrounded by double underscores, e.g., __NOTOC__ or other keywords using parser function syntax
  2. Variables: uppercase words surrounded by double braces (thus resembling templates), e.g. {{PAGENAME}}
  3. Parser functions: keywords in double braces with parameters after a colon (some beginning with #), e.g. {{#expr:2+2}}

Some magic words are case-insensitive, but not all. White space is stripped from the start and end of keywords and parameters, as in template syntax.

Page-dependent magic words will affect or return data about the current page, even if the word is added through a transcluded template or included system message.

It is possible to substitute parser functions and most variables in the same way that templates are substituted (using the subst: keyword). This causes their current value (as evaluated at the time of substitution) to be written into the wikitext.

[edit] Behavior switches

For documentation, see the Behavior switches section of the MediaWiki page, unless otherwise stated.
Code Notes
__TOC__ Places the page's table of contents (TOC) at the word's position.
__FORCETOC__ Forces the TOC to appear in its default position immediately before the page's first section (first heading). Can be used anywhere on a page.
__NOTOC__ Suppresses the appearance of the page's TOC. Can be used anywhere on a page.
__NOEDITSECTION__ Hides the "edit" links normally beside all headings on the page. To hide the edit link beside a particular heading, specify the heading using e.g. an HTML tag such as <h2>[Heading]</h2> rather than with the usual wiki equals-signs syntax (e.g. == [Heading] ==).
__NEWSECTIONLINK__ On non-talk pages, adds a "Add topic" link as a means to add a new section to the page.
__NONEWSECTIONLINK__ Removes the "Add topic" link (the add-new-section link) on talk pages.
__NOGALLERY__ Replaces thumbnails on a category page with normal links.
__HIDDENCAT__ Makes a category hidden when included on that category's page.
__INDEX__ Instructs search engines to index the page.
__NOINDEX__ Instructs search engines not to index the page. See Wikipedia:Controlling search engine indexing.
__STATICREDIRECT__ Prevents the link on a redirection page from being updated automatically when the page to which it redirects is moved (and "Update any redirects that point to the original title" is selected). Also instructs interwiki bots to treat the page as if an article.
__DISAMBIG__ Marks a page as a disambiguation page, adds it to Special:DisambiguationPages and places inward links in Special:DisambiguationPageLinks. (See mw:Extension:Disambiguator.)
{{DEFAULTSORT:sortkey}} Sets the default sort key (the index) under which the page is categorised.

[edit] Variables

For more documentation, see this Wikipedia page.

The example outputs in the following table are those that would be produced on the page "Help:Magic words/subpage".

Variable  Example output  Notes 
{{PAGENAME}} Magic words/subpage Current page's name excluding namespace.
{{NAMESPACE}} Help Current page's namespace.
{{NAMESPACENUMBER}} 12 The namespace number of the current page.
{{FULLPAGENAME}} Help:Magic words/subpage Current page's name including namespace (i.e. FULLPAGENAME = NAMESPACE:PAGENAME).
{{BASEPAGENAME}} Magic words/subpage Current page's name excluding namespace and any subpage element or elements (i.e. the first forward-slash ("/") and anything following; in effect, a subpage's parent's name less its namespace).
{{SUBPAGENAME}} Magic words/subpage Returns either the subpage part of the page's name – i.e. whatever follows the last forward-slash ("/") in the page's name – or, if the page is not a subpage (i.e. its name contains no forward-slashes), {{BASEPAGENAME}} (PAGENAME = BASEPAGENAME/SUBPAGENAME).
{{ARTICLEPAGENAME}}
{{SUBJECTPAGENAME}}
Help:Magic words/subpage
Help:Magic words/subpage
Current page's associated non-talk page.
{{ARTICLESPACE}}
{{SUBJECTSPACE}}
Help
Help
Current page's associated non-talk namespace.
{{TALKPAGENAME}} Help talk:Magic words/subpage Name of talk page associated with current page.
{{TALKSPACE}} Help talk Associated talk page's namespace.
{{FULLPAGENAMEE}},
{{PAGENAMEE}},
   (etc.)
Help:Magic_words/subpage,
Magic_words/subpage,
(etc.)
Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki URLs (i.e. with underscores replacing spaces).
Note: The magic words above can also take a parameter, in order to parse values on a page other than the current page. A colon (:) is used to pass the parameter, rather than a pipe (|) that is used in templates, like {{MAGICWORD:value}}. For example, {{TALKPAGENAME:Wikipedia:MOS}} returns Wikipedia talk:MOS on any page. See meta:Help:Page name for more details of parser functions.
Code Example Notes
{{SITENAME}} Gunsopedia
{{SERVER}} http://www.gunsopedia.com
{{SERVERNAME}} www.gunsopedia.com
{{CURRENTVERSION}} 1.20.0 Returns current MediaWiki version.

[edit] Other variables by type

Date and time Revision data Statistics
Universal time
  • {{CURRENTYEAR}}
  • {{CURRENTMONTH}}
  • {{CURRENTMONTHNAME}}
  • {{CURRENTMONTHABBREV}}
  • {{CURRENTDAY}}
  • {{CURRENTDAY2}}
  • {{CURRENTDOW}}
  • {{CURRENTDAYNAME}}
  • {{CURRENTTIME}}
  • {{CURRENTHOUR}}
  • {{CURRENTWEEK}}
  • {{CURRENTTIMESTAMP}}
Local website time
  • {{LOCALYEAR}}
  • {{LOCALMONTH}}
  • {{LOCALMONTHNAME}}
  • {{LOCALMONTHABBREV}}
  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}
  • {{LOCALDAYNAME}}
  • {{LOCALTIME}}
  • {{LOCALHOUR}}
  • {{LOCALWEEK}}
  • {{LOCALTIMESTAMP}}
  • {{REVISIONID}}a
  • {{REVISIONDAY}}
  • {{REVISIONDAY2}}
  • {{REVISIONMONTH}}
  • {{REVISIONYEAR}}
  • {{REVISIONTIMESTAMP}}
  • {{REVISIONUSER}}
  • {{NUMBEROFPAGES}}
  • {{NUMBEROFARTICLES}}
  • {{NUMBEROFFILES}}
  • {{NUMBEROFEDITS}}
  • {{NUMBEROFVIEWS}}
  • {{NUMBEROFUSERS}}
  • {{NUMBEROFADMINS}}
  • {{NUMBEROFACTIVEUSERS}}

a {{REVISIONID}} cannot be substituted and does not function in preview.

[edit] Parser functions

For documentation, see the MediaWiki magic words page or the ParserFunctions Extension page, unless otherwise stated.

[edit] Metadata

Code Notes
{{PAGEID}} Unique page identifier number.
{{PAGESIZE:pagename}} Size of page named pagename in bytes.
{{PROTECTIONLEVEL:action|pagename}} Protection level assigned to action ("edit", "move", etc) on page named pagename.
{{PENDINGCHANGELEVEL}} Protection level for pending changes on the current page.
{{PAGESINCATEGORY:categoryname}} Number of pages in the category named categoryname.
{{NUMBERINGROUP:groupname}} Number of users in the usergroup named groupname.

To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter |R.

[edit] Formatting

Code Notes
{{lc:string}} Converts all characters in string to lower case.
{{lcfirst:string}} Converts first character of string to lower case.
{{uc:string}} Converts all characters in string to upper case.
{{ucfirst:string}} Converts first character of string to upper case.
{{formatnum:unformatted_number}} Adds comma separators to an unformatted_number (e.g. 123456789 becomes 123,456,789). To remove such formatting, use {{formatnum:formatted_number|R}} (i.e. {{formatnum:7,654,321|R}}, for example, produces 7654321).
{{#formatdate:date|format}} Formats a date according to user preferences; a default can be given as an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any of dmy, mdy, ymd or ISO 8601 formats, with the user's preference overriding the specified format.
{{padleft:xyz|stringlength}}
{{padright:xyz|stringlength}}
Pad with zeros to the right or left; an alternative padding string can be given as a third parameter; the alternative padding string may be truncated if its length does not evenly divide the required number of characters.
{{plural:N |singular |plural}} Outputs singular if N is equal to 1, otherwise outputs plural. See the documentation at mediawiki.org for more details.
{{#time:format|object}}
{{#timel:}} (for local time)
Used to format dates and times. #timel is based on local time as defined for the entire wiki; for the English Wikipedia, where local time is set to UTC, this is identical to #time. (See mw:Help:Extension:ParserFunctions##time.)
{{gender:user |m_out |f_out |u_out}} Outputs m_out, f_out or u_out according to whether the gender specified in user's preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see mw:Help:Magic words#gender.
{{#tag:tag|content |p1=v1 |p2=v2}} An equivalent to the HTML <tag>...</tag><code> that is useful when e.g. nesting references.

[edit] Paths

Code Notes
<code> {{localurl:pagename |query}} Relative path to pagename. The query parameter is optional.
{{fullurl:pagename |query}} Absolute path, without protocol prefix (i.e. without "" etc), to pagename. The query parameter is optional.
{{canonicalurl:pagename |query}} Absolute path, including protocol prefix, to pagename. The query parameter is optional.
{{filepath:filename}} Absolute path to the media file filename.
{{urlencode:string}} Encodes string for use in URL query strings; {{urlencode:test string}}, for example, produces: test+string. To encode string for use in URL paths or MediaWiki page names, append, respectively, |PATH or |WIKI (to produce "test%20string" or "test_string").
{{anchorencode:string}} Input encoded for use in MediaWiki URL section anchors.
{{ns:n}} Returns the name of the namespace whose index is the number n. For MediaWiki URLs, use {{nse:}}.
{{#rel2abs:path}} Converts a relative file path to an absolute path. (See mw:Help:Extension:ParserFunctions##rel2abs.)
{{#titleparts:pgname|num|first_seg}} Splits the page pgname's title into a number of segments. (See mw:Help:Extension:ParserFunctions##titleparts.)

[edit] Conditional

Some parameters are optional. For documentation, see mw:Help:Extension:ParserFunctions. For #switch specifically, see Wikipedia:Help:Switch parser function.
Code Notes
{{#expr:expression}} Evaluates expression (see m:Help:Calculation).
{{#if:string |result1 |result2}} Outputs result2 if string is empty, otherwise outputs result1.
{{#ifeq:string1|string2 |result1 |result2}} Outputs result1 if string1 and string2 are equal (alphabetically or numerically), otherwise outputs result2.
{{#iferror:test_string |result1 |result2}} Outputs result1 if test_string generates a parsing error, otherwise outputs result2.
{{#ifexpr:expression |result1 |result2}} Outputs result1 if expression is true, otherwise outputs result2.
{{#ifexist:pagetitle |result1 |result2}} Outputs result1 if the page [[pagetitle]] exists, otherwise outputs result2. Note that underscores are needed for spaces in namespaces.
{{#switch:string |c1=r1 |c2=r2 ... |default}} Outputs r1 if string is c1, r2 if string is c2, etc, otherwise outputs default (if provided).

If, in these conditional functions, empty unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. {{{1|}}}, {{{2|}}}, etc., rather than {{{1}}}, {{{2}}}, etc.).

[edit] Other

[edit] See also

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox