Help:Magic words
From Tomes Support Wiki
Magic words are strings of text that MediaWiki associates with a return value or function, such as time, site details, or page names. This page is about usage of standard magic words; for a technical reference, see {{ #ifeq:
Tomes Support Wiki
| MediaWiki | Manual:Magic words | Manual:Magic words }}.
There are three general types of magic words:
- Behavior switches: these are uppercase words surrounded by double underscores, e.g. __FOO__
- Variables: these are uppercase words surrounded by double braces, e.g.
. As such, they look a lot like templates.- <nowiki>{{FOO}}</nowiki>
- Parser functions: these take parameters and are either of the form
or- <nowiki>{{foo:...}}</nowiki>
. See also {{ #ifeq:- <nowiki>{{#foo:...}}</nowiki>
Tomes Support Wiki
| MediaWiki | Help:Extension:ParserFunctions | Help:Extension:ParserFunctions }}.
Page-dependent magic words will affect or return data about the current page (by default), even if the word is added through a transcluded template or included system message.
Contents |
Behavior switches
A behavior switch controls the layout or behaviour of the page and can often be used to specify desired omissions and inclusions in the content.
| Word | Description | Versions | |||
|---|---|---|---|---|---|
| Table of contents | |||||
| Hides the table of contents (TOC). | ||||
| Forces the table of content to appear at its normal position (above the first header). | ||||
| Places a table of contents at the word's current position (overriding ). If this is used multiple times, the table of contents will appear at the first word's position. | ||||
| Editing | |||||
| Hides the section edit links beside headings. | ||||
| Adds a link ("+" by default) beside the "edit" tab for adding a new section on a non-talk page (see {{ #ifeq:
Tomes Support Wiki | MediaWiki | Adding a section to the end | Adding a section to the end
}}). | 1.7+ |
| Removes the link beside the "edit" tab on pages in talk namespaces. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.15+ | 1.15+
}} |
| Categories | |||||
| Used on a category page, replaces thumbnails in the category view with normal links. | 1.7+ | |||
| Used on a category page, hides the category from the lists of categories in its members and parent categories (there is an option in the user preferences to show them). | 1.13+ | |||
| Language conversion | |||||
| On wikis with language variants, don't perform any content language conversion (character and phase) in article display; for example, only show Chinese (zh) instead of variants like zh_cn, zh_tw, zh_sg, or zh_hk. | ||||
| On wikis with language variants, don't perform language conversion on the title (all other content is converted). | ||||
| Other | |||||
| No effect. | ||||
| Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace. Removed in {{ #ifeq:
Tomes Support Wiki | MediaWiki | 19213 | 19213
}}. | 1.1 - 1.8 |
| Tell search engines to index the page (overrides {{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgArticleRobotPolicies | $wgArticleRobotPolicies
}}, but not robots.txt). | 1.14+ |
| Tell search engines not to index the page (ie, do not list in search engines' results). | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.14+ | 1.14+
}} |
| On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title". | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.13+ | 1.13+
}} |
Variables
Variables return information about the current page, wiki, or date. Their syntax is similar to templates. Variables marked as "[expensive]" are tracked by the software, and the number that can be included on a page is limited.
If a template name conflicts with a variable, the variable will be used (so to transclude the template Template:PAGENAME you would need to write). In some cases, adding parameters will force the parser to invoke a template; for example,
<nowiki>{{</nowiki>{{ns:10}}:PAGENAME<nowiki>}}</nowiki>
transcludes Template:CURRENTDAYNAME not the variable.
<nowiki>{{CURRENTDAYNAME|x}}</nowiki>
Date and time
The following variables return the current date and time in UTC.
Due to MediaWiki and browser caching, these variables frequently show when the page was cached rather than the current time.
| Variable | Output | Description | Versions |
|---|---|---|---|
| Year | |||
| 2013 | Year | |
| Month | |||
| 06 | Month (zero-padded number) | |
| June | Month (name) | |
| June | Month (genitive form) | |
| Jun | Month (abbreviation) | 1.5+ |
| Day | |||
| 19 | Day of the month (unpadded number) | |
| 19 | Day of the month (zero-padded number) | 1.6+ |
| 3 | Day of the week (unpadded number) | |
| Wednesday | Day of the week (name) | |
| Time | |||
| 22:50 | Time (24-hour HH:mm format) | |
| 22 | Hour (24-hour zero-padded number) | |
| Other | |||
| 25 | Week (number) | |
| 20130619225043 | YYYYMMDDHHmmss timestamp | 1.7+ |
The following variables do the same as the above, but using the site's server config or $wgLocaltimezone.
-
- <nowiki>{{LOCALYEAR}}</nowiki>
-
- <nowiki>{{LOCALMONTH}}</nowiki>
-
- <nowiki>{{LOCALMONTHNAME}}</nowiki>
-
- <nowiki>{{LOCALMONTHNAMEGEN}}</nowiki>
-
- <nowiki>{{LOCALMONTHABBREV}}</nowiki>
-
- <nowiki>{{LOCALDAY}}</nowiki>
-
- <nowiki>{{LOCALDAY2}}</nowiki>
-
- <nowiki>{{LOCALDOW}}</nowiki>
-
- <nowiki>{{LOCALDAYNAME}}</nowiki>
-
- <nowiki>{{LOCALTIME}}</nowiki>
-
- <nowiki>{{LOCALHOUR}}</nowiki>
-
- <nowiki>{{LOCALWEEK}}</nowiki>
-
- <nowiki>{{LOCALTIMESTAMP}}</nowiki>
- For more thorough time formatting, you may want to install Extension:ParserFunctions to use the #time parser function
Technical metadata
Revision variables return data about the latest edit to the current page, even if viewing an older version of the page.
| Variable | Output | Description | Versions | |||
|---|---|---|---|---|---|---|
| Site | ||||||
| Tomes Support Wiki | The wiki's site name ({{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgSitename | $wgSitename
}}). | |
| http://www.iphonebookshelf.com | domain URL ({{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgServer | $wgServer
}}) | |
| www.iphonebookshelf.com | domain name (No longer dependent on {{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgServerName | $wgServerName
}} as of version 1.17) | |
| | Outputs a unicode-directional mark that matches the wiki's default language's direction (on left-to-right wikis, on right-to-left wikis), useful in text with multi-directional text. | 1.7+ | |||
| /w | relative script path ({{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgScriptPath | $wgScriptPath
}}) | |
| /w/skins | relative style path ({{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgStylePath | $wgStylePath
}}) | 1.16+ |
| 1.16.1 | The wiki's MediaWiki version. | 1.7+ | |||
| en en | The wiki's default interface language ({{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgLanguageCode | $wgLanguageCode
}}) | 1.7+ |
| Latest revision to current page | ||||||
| 1103 | Unique revision ID | 1.5+ | |||
| 12 | Day edit was made (unpadded number) | 1.8+ | |||
| 12 | Day edit was made (zero-padded number) | 1.8+ | |||
| 1 | Month edit was made (zero-padded number as of {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.17+ | 1.17+
}}, unpadded number in prior versions) | 1.8+ |
| 2011 | Year edit was made | 1.8+ | |||
| 20110112025906 | Timestamp as of time of edit | 1.8+ | |||
| Pendor | The username of the user who made the most recent edit to the page, or the current user when previewing an edit | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.15+ | 1.15+
}} |
" to get raw numbers. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.13+ | 1.13+
}} | ||
| protection level | Outputs the protection level (e.g. 'autoconfirm', 'sysop') for a given action (e.g. 'edit', 'move') on the current page or an empty string if not protected. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.15+ | 1.15+
}} |
| Affects page content | ||||||
| Format the current page's title header. The value must be equivalent to the default title: only capitalization changes and replacing spaces with underscores. It can be disabled or enabled by {{ #ifeq:
Tomes Support Wiki | MediaWiki | $wgAllowDisplayTitle | $wgAllowDisplayTitle
}}; disabled by default before 1.10+, enabled by default thereafter. | 1.7+ | |
| Used for categorizing pages, sets a default category sort key. For example if you put at the end of John Smith, the page would be sorted under "S" by default in categories. | 1.10+ | ||||
Statistics
Numbers returned by these variables normally contain separators (commas or spaces, depending on the local language), but can return raw numbers with the ":R" flag (for example,→ 244 and
<nowiki>{{NUMBEROFPAGES}}</nowiki>
→ 244). Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example
<nowiki>{{NUMBEROFPAGES:R}}</nowiki>
and
<nowiki>{{PAGESINCATEGORY:Help}}</nowiki>
). Also applicable to
<nowiki>{{PAGESINCATEGORY:Help|R}}</nowiki>
above.
<nowiki>{{PAGESIZE:</nowiki>''page name''<nowiki>}}</nowiki>
| Variable | Output | Description | Versions | ||||||
|---|---|---|---|---|---|---|---|---|---|
| Entire wiki | |||||||||
| 244 | Number of wiki pages. | 1.7+ | ||||||
| 115 | Number of pages in {{ #ifeq:
Tomes Support Wiki | MediaWiki | content namespaces | content namespaces
}}. | ||||
| 5 | Number of uploaded files. | 1.5+ | ||||||
| 286 | Number of page edits. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.10+ | 1.10+
}} | |||
| 84,351 | Number of page views. Usually useless on a wiki using caching. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.14+ | 1.14+
}} | |||
| 1 | Number of registered users. | 1.7+ | ||||||
| 1 | Number of users in the sysop {{ #ifeq:
Tomes Support Wiki | MediaWiki | group | group
}}. | 1.7+ | |||
| 1 | Number of active users, based on the criteria used in Special:Statistics. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.15+ | 1.15+
}} | |||
| 45 45 | [expensive] Number of pages in the given category. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.13+ | 1.13+
}} | |||
| 1 1 ({{NUMBERINGROUP:bureaucrat}} used here) | Number of users in a specific {{ #ifeq:
Tomes Support Wiki | MediaWiki | group | group
}}. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.14+ | 1.14+
}} |
| not enabled | Number of pages in the given namespace (replace index with the relevant namespace index). For instance, will output the number of category pages. differs from in that the former includes redirects and disambiguation pages. Disabled by default, enable with {{ #ifeq: Tomes Support Wiki | MediaWiki | $wgAllowSlowParserFunctions | $wgAllowSlowParserFunctions
}}. | 1.7+ | |||
Page names
| Variable | Output | Description | Versions |
|---|---|---|---|
| Help:Magic words | Namespace and page title. | 1.6+ |
| Magic words | Page title. | |
| Magic words | Page title excluding the current subpage and namespace ("Title/foo" on "Title/foo/bar").
For more complex splitting, use from ParserFunctions extension. | 1.7+ |
| Magic words | The subpage title ("foo" on "Title/foo"). | 1.6+ |
| Help:Magic words | The namespace and title of the associated content page. | 1.7+ |
| Help talk:Magic words | The namespace and title of the associated talk page. | 1.7+ |
and
<nowiki>{{BASEPAGENAME}}</nowiki>
magic words only work in namespaces that have subpages enabled. See {{ #ifeq:
<nowiki>{{SUBPAGENAME}}</nowiki>
Tomes Support Wiki
| MediaWiki | Manual:$wgNamespacesWithSubpages | Manual:$wgNamespacesWithSubpages }} for information on enabling subpages.
The following are equivalents encoded for use in MediaWiki URLs (i.e. spaces replaced with underscores and some characters percent-encoded):
-
- <nowiki>{{FULLPAGENAMEE}}</nowiki>
-
- <nowiki>{{PAGENAMEE}}</nowiki>
-
- <nowiki>{{BASEPAGENAMEE}}</nowiki>
-
- <nowiki>{{SUBPAGENAMEE}}</nowiki>
-
- <nowiki>{{SUBJECTPAGENAMEE}}</nowiki>
-
- <nowiki>{{TALKPAGENAMEE}}</nowiki>
As of {{ #ifeq:
Tomes Support Wiki
| MediaWiki | 1.15+ | 1.15+ }}, these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:
-
→ Main Page- <nowiki>{{PAGENAME:Template:Main Page}}</nowiki>
, may produce unexpected results when handled with these magic words, e.g.
*
. See bugs {{ #ifeq:
<nowiki>{{PAGESINCATEGORY:{{PAGENAME}}}}</nowiki>
Tomes Support Wiki
| MediaWiki | 14779 | 14779 }}, {{ #ifeq:
Tomes Support Wiki}}.|
}}Warning Warning: {{#if: Page titles containing certain characters, such as single quotes (') or asterisks , may produce unexpected results when handled with these magic words, e.g. . See bugs {{ #ifeq: Tomes Support Wiki | MediaWiki | 14779 | 14779 }}, {{ #ifeq: Tomes Support Wiki}}.| | Page titles containing certain characters, such as single quotes (') or asterisks , may produce unexpected results when handled with these magic words, e.g. . See bugs {{ #ifeq: Tomes Support Wiki | MediaWiki | 14779 | 14779 }}, {{ #ifeq: Tomes Support Wiki}}. |
Namespaces
| Variable | Output | Description | Versions |
|---|---|---|---|
| Help | Name of the page's namespace | |
| Help Help | Name of the associated content namespace | 1.7+ |
| Help talk | Name of the associated talk namespace | 1.7+ |
The following are equivalents encoded for use in MediaWiki URLs (spaces replaced with underscores and some characters percent-encoded):
-
- <nowiki>{{NAMESPACEE}}</nowiki>
-
- <nowiki>{{SUBJECTSPACEE}}</nowiki>
-
- <nowiki>{{TALKSPACEE}}</nowiki>
As of {{ #ifeq:
Tomes Support Wiki
| MediaWiki | 1.15+ | 1.15+ }}, these can take a page name parameter and will return the namespace of the page name parameter, instead of the current page's:
-
→ Template- <nowiki>{{NAMESPACE:Template:Main Page}}</nowiki>
-
→ Template- <nowiki>{{SUBJECTSPACE:Template:Main Page}}</nowiki>
-
→ Template talk- <nowiki>{{TALKSPACE:Template:Main Page}}</nowiki>
Parser functions
Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is sometimes prefixed with a hash to distinguish them from templates.
This page only describes parser functions that are integral to the MediaWiki software. Other parser functions may be added by MediaWiki extensions such as the {{ #ifeq:
Tomes Support Wiki
| MediaWiki | ParserFunctions extension | ParserFunctions extension }}. For those see Help:Extension:ParserFunctions.
URL data
| Parser function | Input → Output | Description | Versions | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| → /wiki/MediaWiki {{localurl:MediaWiki|printable=yes}} → /w/index.php?title=MediaWiki&printable=yes | The relative path to the title. | |||||||||||||
| → http://www.iphonebookshelf.com/wiki/Category:Top_level → http://www.iphonebookshelf.com/w/index.php?title=Category:Top_level&action=edit | The absolute path to the title. This will also resolve Interwiki prefixes. | 1.5+ | ||||||||||||
| → → | The absolute URL to a media file. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.12+ | 1.12+
}} | |||||||||
(or )
| (or → x+y+z+%C3%A1+%C3%A9 → x_y_z_%C3%A1_%C3%A9 → x%20y%20z%20%C3%A1%20%C3%A9 | The input encoded for use in URLs. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.7+ | 1.7+
}} (or {{ #ifeq: Tomes Support Wiki | MediaWiki | 1.17+ | 1.17+
}}) Tomes Support Wiki | MediaWiki | 1.17+ | 1.17+
}} Tomes Support Wiki | MediaWiki | 1.17+ | 1.17+
}} |
| → x_y_z_.C3.A1_.C3.A9 | The input encoded for use in URL section anchors (after the '#' symbol in a URL). | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.8+ | 1.8+
}} |
Namespaces
returns the localized name for the namespace with that index.
<nowiki>{{ns:}}</nowiki>
is the equivalent encoded for MediaWiki URLs. It does the same, but it replaces spaces with underscores, making it usable in external links.
<nowiki>{{nse:}}</nowiki>
| Content namespaces | Talk namespaces | |||
|---|---|---|---|---|
| Usage | Output | Usage | Output | |
or
| Media | |||
or
| Special | |||
or
| or
| Talk | ||
or
| User | or
| User talk | |
or
| Tomes Support Wiki | or
| Tomes Support Wiki talk | |
or or
| File | or or
| File talk | |
or
| MediaWiki | or
| MediaWiki talk | |
or
| Template | or
| Template talk | |
or
| Help | or
| Help talk | |
or
| Category | or
| Category talk | |
Formatting
| Usage | Input → Output | Description | Version | ||||||
|---|---|---|---|---|---|---|---|---|---|
| → data center | The lowercase input. | 1.5+ | ||||||
| → dATA center | The input with the very first character lowercase. | 1.5+ | ||||||
| → TEXT TRANSFORM | The uppercase input. | 1.5+ | ||||||
| → Text TRANSFORM | The input with the very first character uppercase. | 1.5+ | ||||||
|
→ 987,654,321.654321
→ 987654321.654321 | The input with decimal and decimal group separators, and localized digit script, according to the wiki's default locale. The parameter can be used to unformat a number, for use in mathematical situations. | 1.7+ {{ #ifeq: Tomes Support Wiki | MediaWiki | 1.13+ | 1.13+
}} | |||
|
→ 2009 DeC 25 (your pref), 2009 DeC 25 (default)
→ 25 Dec 2009 (your pref), 25 Dec 2009 (default)
→ December 25, 2009 (your pref), December 25, 2009 (default)
→ 2009-12-25 (your pref), 2009-12-25 (default)
→ DecEmber 25 (your pref), DecEmber 25 (default)
|
| {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.15+ | 1.15+
}} | |||
| → 00xyz → __xyz → abxyz → xyz → x (first character of the string) | Inserts a string of padding characters (character chosen in third parameter; default '0') of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. produces 044. The padding string may be truncated if its length does not evenly divide the required number of characters. {{ #ifeq: Tomes Support Wiki | MediaWiki | bug | bug
}} (fixed in {{ #ifeq: Tomes Support Wiki | MediaWiki | r45734 | r45734
}}): multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters. | 1.8+ |
| → xyz00 → xyz__ → xyzab → xyz → x | Identical to padleft, but adds padding characters to the right side. | |||||||
| → is → are | Outputs the correct given pluralization form (parameters except first) depending on the count (first parameter). Plural transformations are used for languages like Russian based on "count mod 10". | |||||||
| Outputs the correct inflected form of the given word described by the inflection code after the colon (language-dependent). Grammar transformations are used for inflected languages like Polish. See also {{ #ifeq:
Tomes Support Wiki | MediaWiki | Manual:$wgGrammarForms | Manual:$wgGrammarForms
}}. | 1.7+ |
Miscellaneous
| Usage | Output | Description | Version | |||
|---|---|---|---|---|---|---|
→ Edit (depends on user language, try: fr •ja) | Internationalizes (translates) the given interface (MediaWiki namespace) message into the user language. Note that this can damage/confuse cache consistency, see bug 14404. | |||||
| language code العربية ไทย | The native name for the given language code, in accordance with ISO 639. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.7+ | 1.7+
}} |
| No such special page Special:UserLogin | The localized name for the given canonical Special: page. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.9+ | 1.9+
}} |
| (depends on parser tag) | Alias for XML-style parser or extension tags, but parsing wiki code. Inner content can be passed as first parameter, and attributes as subsequent ones:
tagname attribute1="value1" attribute2="value2" content tagname → tagname content attribute1=value1 attribute2=value2 Warning : You must write tagname attribute1=value1 attribute2=value2 to pass an empty content. | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.12+ | 1.12+
}} |
| (depends on the named user's gender) | A switch for the gender set in Special:Preferences | {{ #ifeq:
Tomes Support Wiki | MediaWiki | 1.15+ | 1.15+
}} |