Help:Magic words

= Magic words of MediaWiki =
 * This page is a copy of at . Updated July 2, 2007.

This is an organized index of Magic words used in MediaWiki.

A "magic word" is a symbol which is recognized by the MediaWiki software and which when seen in the non-commented text of the page, triggers the software to do something other than display that symbol, or transclude a page with that name, but instead to use the symbol directly. A magic word can be
 * an upper case word, preceded and followed by two underscores, e.g.  
 * an XML object, coded similar to HTML, preceded by "<" (and for the end tag "/") and followed by ">", as in &lt;nowiki>...&lt;/nowiki>
 * a parser function: similar to a template, a word preceded by the symbols " ", and optionally parameter definitions between pipe characters, except that the part before the first pipe (or without pipes, the text between the braces) contains a colon (":"), e.g.  and
 * a variable: similar to a template without parameters, a word preceded by the symbols " ", except the word used is in all upper case, e.g.  27 
 * a template modifier
 * an image modifier

If a page in the template namespace has the same name as a magic word, the magic word will be invoked instead. If you discover you absolutely have to define a template with the same name as a magic word, prefix the name of the template with "msg:" or the name of the template namespace ("Template:"). See below for further details if you need this feature.

Tags which are used on this page such as "[MW1.5+]" indicate the version that first supported the magic word. "XYZ" indicates user input, which is used in the example.

Table of contents

 * For details see m:Help:Section

Variables

 * For details see m:Help:Variable

Time
The time in UTC. Note that if the page was displayed by the same user and has not changed (has not been edited) since the last time it was displayed, it is possible that the page may be cached (by the user's browser) and the displayed time or date may not change. Also, if a heavily used page, rather than freshly rendered by the software each time it is generated, is instead being retrieved from a caching system (such as the main page on Wikipedia) the date or time may not change from the last time the page was originally retrieved by the caching hardware or software.

Local time
The time depending on the local timezone of the wiki (not depending on the timezone in the user's preference settings).


 * See also the ParserFunction #time:

Statistics
Statistics variables give thousands separators unless ":R" for "raw" is added (actually, these versions are parser functions).

Parser functions

 * For details see m:Help:Parser function.

Not working at the position of the page where the tag is located but on the page header, and throughout the page, respectively (see below):
 * DISPLAYTITLE: allow the page header to be different from the page name.
 * DEFAULTSORT: Sets a default category sort key for the page.

Formatting
With regard to #language, see also:
 * List of Wikipedias/local names - shows both names for all languages, without automatic comparison
 * List of Wikipedias/local names/diff - values of #language for which contains a different name.
 * List of Wikipedias/local names/diff 1 - for languages where the two names are different, shows both; due to the pre-expand include size maximum of 2,048,000 bytes the end of the table is messed up

Image modifiers

 * For details see wikipedia:Wikipedia:Extended image syntax.

These are image modifiers used in  links. Some are mutually exclusive, and then the last specified wins.

Size
The last unrecognized modifier is used as caption for framed images or together with thumbnails. It's also used as description alt=text.

Position

 * For details see m:Help:Images and other uploaded files

The positions are mutually exclusive; the last specified wins. m:Template:- can stop floating. For inline images only modifier px (see above) is supported.

Language-dependent word conversions
"Grammar" and "Plural" are language-dependent functions, defined in, , etc. (note that in PHP, the modulo operator is the percent sign).

"Grammar" can either be applied to predefined words only, or to arbitrary words, depending on whether the definition is just a 2D array, or involves string manipulations. See also wikipedia:cs:Šablona:Wikivar/GRAMMAR.

"Plural" is a site-language-dependent switch function, controlled by function convertPlural in Language.php (which distinguishes between 1 and "not 1"), for some languages overridden in Languagexx.php, e.g. for French (which distinguishes between <=1 and >1) and Russian (oddly, first option is 1, 21, 31,.., 91, 101, 121, .., second is 2, 3, 4, 22, 23, 24, 31, 32, 33, 41,.., 94, 102, 103, 104,.., 122, 123,.., and else the third).

As opposed to ParserFunctions, "plural" accepts points and commas in numbers and interprets them in a site-language-specific way (depending on $separatorTransformTable in Messagesxx.php); on this site:
 * 1 a gives 1 a
 * NaN as gives NaN as

(on e.g. the German and the Dutch sites reversed w.r.t. the result on English sites).

"Plural" is used in various system messages, e.g. MediaWiki:Nmembers, where it uses interface language instead of site language.