Help:Magic words

From the Tesseract Wiki, the wiki for all things Marvel Cinematic Universe
Jump to navigation Jump to search

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 explains only the standard magic words, for information on parser functions (magic words that act similar to variables but take 1 or more parameters) see Help:Parser functions.

General information[edit source]

There are three general types of magic words:

Variables and parser functions can use subst:, just like templates. 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.

The software generally interprets magic words in the following way:

  • Magic words are case sensitive.
  • White space is generously allowed for readability. It will be stripped from the start and end of their keywords and parameters (as is also done inside templates).
  • They can be transcluded, even variables "about the current page". This is ensured by the parsing order.
  • Instead of magically transforming into HTML instructions, <nowiki> tags remove this magic so a magic word can itself be displayed (documented), e.g. <nowiki>{{#magic:}}</nowiki> or {{#magic:<nowiki />}}.

Magic words compared to templates:

  • As with templates, magic words can be transcluded and substituted.
  • The names of magic words are purposely chosen to be unlike the names of templates, and vice versa. Many parser function names will begin with a # (pound), but template names will not start with a #, and probably not end in a : (colon), or be all-uppercase.
  • The first parameter's syntax differs. In {{#magic: p1 | p2 | p3}}, the name is #magic and it is followed by an unspaced : and a required input parameter, p1. With a template, p1 is optional and it is preceded by a | (pipe) instead of a :, e.g. {{template|p1}}.

Behavior switches[edit source]

A behavior switch controls the layout or behavior of the page (if supported by the skin) and can often be used to specify desired omissions and inclusions in the content.

Word Description
Table of contents
__NOTOC__ Hides the table of contents (TOC).
__FORCETOC__ Forces the table of contents to appear at its normal position (before the first header, overriding __NOTOC__).
__TOC__ notoc>__NOTOC__</>). If this is used multiple times, the table of contents will appear at the first word's position.
Editing
__NOEDITSECTION__ Hides the section edit links beside headings. This is especially useful where a heading is created from within a template: the normal wiki section-edit would in this case edit the template code, which is usually not what the user intends. Use of this in a template will extend the effect to that template, the pages it's included on, and any other templates included on the same page. For a workaround, see here.
__NEWSECTIONLINK__ Adds a link beside the "Edit" tab for adding a new section on a non-talk page (see Adding a section to the end).
__NONEWSECTIONLINK__ Removes the link beside the "Edit" tab on pages in talk namespaces.
Categories
__NOGALLERY__ Used on a category page, replaces thumbnails in the category view with normal links.
__HIDDENCAT__ 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).
__EXPECTUNUSEDCATEGORY__ Used on a category page, removes the category from Special:UnusedCategories.
Language conversion
__NOCONTENTCONVERT__
__NOCC__
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.
__NOTITLECONVERT__
__NOTC__
On wikis with language variants, don't perform language conversion on the title (all other content is converted).
Other
__START__ No effect. Was used to point where database message starts after comment that should not be transcluded.
__END__ Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace.
__INDEX__ Tell search engines to index the page (overrides $wgArticleRobotPolicies but not robots.txt). It obeys $wgExemptFromUserRobotsControl variable.
__NOINDEX__ Tell search engines not to index the page (i.e. do not list in search engines' results). It obeys $wgExemptFromUserRobotsControl variable.
__STATICREDIRECT__ 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" (which requires $wgFixDoubleRedirects).
From Extensions
Extension Word Description
GlobalUserPage __NOGLOBAL__ Disables the global user page. If present on the central user page, will prevent it from being displayed on remote wikis, and it also determines whether a link to a user page on remote wiki should be red or blue.
Disambiguator __DISAMBIG__ Identifies a disambiguation page.

Variables[edit source]

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 {{Template:PAGENAME}}). In some cases, adding parameters will force the parser to invoke a template; for example, {{CURRENTDAYNAME|x}} transcludes Template:CURRENTDAYNAME, not the variable.

Date and time[edit source]

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.

The use of those variables cause pages to be cached for a more limited number of seconds. This is configured in MagicWordFactory.

The date and time magic words are formatted in the wiki content language and depend on the page content language.

Variable Output Description
Year
{{CURRENTYEAR}} 2024 Year
Month
{{CURRENTMONTH}} 07 Month (zero-padded number)
{{CURRENTMONTH1}} 7 Month (unpadded number)
{{CURRENTMONTHNAME}} July Month (name)
{{CURRENTMONTHNAMEGEN}} July Month (genitive form)
{{CURRENTMONTHABBREV}} Jul Month (abbreviation)
Day
{{CURRENTDAY}} 3 Day of the month (unpadded number)
{{CURRENTDAY2}} 03 Day of the month (zero-padded number)
{{CURRENTDOW}} 3 Day of the week (unpadded number), 0 (for Sunday) through 6 (for Saturday)
{{CURRENTDAYNAME}} Wednesday Day of the week (name)
Time
{{CURRENTTIME}} 02:31 Time (24-hour HH:mm format)
{{CURRENTHOUR}} 02 Hour (24-hour zero-padded number)
Other
{{CURRENTWEEK}} 27 Week (number)
{{CURRENTTIMESTAMP}} 20240703023156 YYYYMMDDHHmmss timestamp

The following variables do the same as the preceding ones but using the site's server config or $wgLocaltimezone.

  • {{LOCALYEAR}}
  • {{LOCALMONTH}}
  • {{LOCALMONTH1}}
  • {{LOCALMONTHNAME}}
  • {{LOCALMONTHNAMEGEN}}
  • {{LOCALMONTHABBREV}}
  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}
  • {{LOCALDAYNAME}}
  • {{LOCALTIME}}
  • {{LOCALHOUR}}
  • {{LOCALWEEK}}
  • {{LOCALTIMESTAMP}}

For more thorough time formatting, or to output the current year and week with better compliance with ISO-8601, you may want to use the #time parser function provided by Extension:ParserFunctions.

Technical metadata[edit source]

Variable Output Description
Site
{{SITENAME}} Tesseract Wiki The wiki's site name ($wgSitename).
{{SERVER}} https://tesseract.wiki Domain URL ($wgServer).
{{SERVERNAME}} tesseract.wiki Subdomain and domain name (not dependent on $wgServerName).
{{DIRMARK}}

{{DIRECTIONMARK}}


Outputs a Unicode directional mark that matches the wiki's default language's direction (&lrm; on left-to-right wikis, &rlm; on right-to-left wikis), useful in text with multi-directional text. It depends on the page content language.
{{SCRIPTPATH}} Relative script path ($wgScriptPath).
{{STYLEPATH}} /skins Relative style path ($wgStylePath).
{{CURRENTVERSION}} 1.39.5 The wiki's MediaWiki version.
{{CONTENTLANGUAGE}}

{{CONTENTLANG}}

en

en

The wiki's default interface language ($wgLanguageCode).
Page
{{PAGEID}} 1344 Returns the page identifier.
{{PAGELANGUAGE}}

{{#language:{{PAGELANGUAGE}}}}

en

English

Returns the language of the current page. The language code that this variable returns can be converted to a language name using {{#language:...}}.
<translate><!--T:1--> Translated unit. Language: {{TRANSLATIONLANGUAGE}}.</translate>

<translate><!--T:2--> Not translated unit. Language: {{TRANSLATIONLANGUAGE}}.</translate>

Translated unit. Language: en.

Not translated unit. Language: en.

Must be used in a translated page, inside <translate> tags. Returns the language code of the current translation unit. In a translation page, if the unit has been translated, then it returns translation language. Else, it returns source language. The language code that this variable returns can be converted to a language name using {{#language:...}}. Should only be used by translation admins.
{{PROTECTIONLEVEL:action}} Outputs the protection level (e.g. "autoconfirmed", "sysop") for a given action (e.g. "edit", "move") on the current page. Returns an empty string if not protected.
{{PROTECTIONEXPIRY:action}} Outputs the protection expiry (e.g. "20160418155030", "infinity") for a given action (e.g. "edit", "move") on the current page. Returns "infinity" if not protected.
{{CASCADINGSOURCES}} [Expensive] Returns the sources of any cascading protection acting on the current page. Pages will not return their own title unless they transclude themselves.
Latest revision to current page
{{REVISIONID}} 6940 Unique revision ID. It is empty in preview, thus one can show an error message only in preview. May be disabled in miser mode.
{{REVISIONDAY}} 18 Day edit was made (unpadded number).
{{REVISIONDAY2}} 18 Day edit was made (zero-padded number).
{{REVISIONMONTH}} 04 Month edit was made (zero-padded number).
{{REVISIONMONTH1}} 4 Month edit was made (unpadded number).
{{REVISIONYEAR}} 2023 Year edit was made.
{{REVISIONTIMESTAMP}} 20230418025503 Timestamp as of time of edit.
{{REVISIONUSER}} Elijah The username of the user who made the most recent edit to the page, or the current user when previewing an edit.
{{REVISIONSIZE}} 33037 The size (bytes of wikitext) of the current revision of this page
Affects page content
{{DISPLAYTITLE:title}}
{{DISPLAYTITLE:title|noerror}}
{{DISPLAYTITLE:title|noreplace}}
Format the current page's title header. The value must be equivalent to the default title: only capitalization changes to certain parts of the title (not all) and replacing spaces with underscores are allowed (this can be changed with $wgRestrictDisplayTitle). It can be disabled or enabled by $wgAllowDisplayTitle; enabled by default.

It can take a second argument of noerror or noreplace to suppress error messages when multiple displaytitles are used on one page or to make this displaytitle do nothing if a displaytitle was already specified earlier in the page.

{{DEFAULTSORT:sortkey}}
{{DEFAULTSORTKEY:sortkey}}
{{DEFAULTCATEGORYSORT:sortkey}}
{{DEFAULTSORT:sortkey|noerror}}
{{DEFAULTSORT:sortkey|noreplace}}
Used for categorizing pages, sets a default category sort key. For example if you put {{DEFAULTSORT:Feige, Kevin}} at the end of Kevin Feige, the page would be sorted under "M" by default in categories. It can take a second argument of noerror or noreplace to suppress error messages when multiple defaultsortkeys are used on one page or to make this defaultsort do nothing if a defaultsort was already specified earlier in the page.

Statistics[edit source]

Numbers returned by these variables normally contain separators (commas, dots or spaces, depending on the local language) but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}} → 4,604 and {{NUMBEROFPAGES:R}} → 4604).

Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example {{PAGESINCATEGORY:Help}} and {{PAGESINCATEGORY:Help|R}}, or {{PAGESINCATEGORY:Help|subcats}} and {{PAGESINCATEGORY:Help|subcats|R}}). Also applicable to {{PAGESIZE:page name}} hereinbefore.

The number magic words are formatted in the wiki content language. It depends on the page content language.

Variable Output Description
{{NUMBEROFPAGES}} 4,604 Number of wiki pages.
{{NUMBEROFARTICLES}} 1,721 Number of pages in content namespaces that qualify as articles. See Manual:$wgArticleCountMethod for details.
{{NUMBEROFFILES}} 224 Number of uploaded files.
{{NUMBEROFEDITS}} 9,485 Number of wiki edits.
{{NUMBEROFVIEWS}} Number of page views. Usually useless on a wiki (such as this one) using caching.
{{NUMBEROFUSERS}} 138 Number of registered users.
{{NUMBEROFADMINS}} 2 Number of users in the sysop (we call them Administrators) group.
{{NUMBEROFACTIVEUSERS}} 3 Number of active users, based on the criteria used in Special:Statistics.
{{PAGESINCATEGORY:categoryname}}
{{PAGESINCAT:categoryname}}
59
59
[Expensive] Number of pages (including subcategories and files) in the given category. (Category:Help used for demonstration)
{{PAGESINCATEGORY:categoryname|all}}
{{PAGESINCATEGORY:categoryname|pages}}
{{PAGESINCATEGORY:categoryname|subcats}}
{{PAGESINCATEGORY:categoryname|files}}
59
59
0
0
[Expensive]

Respectively, the number of

  • all pages
  • ordinary pages (excluding subcategories and files)
  • subcategories or
  • files

in the given category. (Category:Help used for demonstration)

{{NUMBERINGROUP:groupname}}
{{NUMINGROUP:groupname}}
1
1
Number of users in a specific group. ({{NUMBERINGROUP:bureaucrat}} used for demonstration)
{{PAGESINNS:index}}
{{PAGESINNAMESPACE:index}}
Not enabled [Expensive] Number of pages in the given namespace (replace index with the relevant namespace index). For instance, {{PAGESINNAMESPACE:14}} will output the number of category pages. {{PAGESINNS:0}} differs from {{NUMBEROFARTICLES}} in that the former includes redirects and disambiguation pages. Disabled by default, enable with $wgAllowSlowParserFunctions.

Page names[edit source]

Variable For current page Description
{{FULLPAGENAME}} Help:Magic words Namespace and full page title (including all subpage levels).
{{PAGENAME}} Magic words Full page title (including all subpage levels) without the namespace.
{{BASEPAGENAME}} Magic words Page title of the page in the immediately superior subpage level without the namespace. Would return Title/Foo on page Help:Title/Foo/Bar.
{{ROOTPAGENAME}} Magic words Name of the root of the current page. Would return Title on page Help:Title/Foo/Bar.
{{SUBPAGENAME}} Magic words The subpage title.

Would return Bar on page Help:Title/Foo/Bar.

If no subpage exists the value of {{PAGENAME}} is returned.

For more complex splitting, use {{#titleparts:}} from the ParserFunctions extension.

{{SUBJECTPAGENAME}}
{{ARTICLEPAGENAME}}
Help:Magic words
Help:Magic words
Full page name of the associated subject (e.g. article or file). Useful on talk pages.
{{TALKPAGENAME}} Help talk:Magic words Full page name of the associated talk page.

None of these are affected by changes to the display title using {{DISPLAYTITLE:xxxx}}; the values returned are the original page title.

The {{BASEPAGENAME}} and {{SUBPAGENAME}} magic words only work in namespaces that have subpages enabled. See $wgNamespacesWithSubpages for information on enabling subpages.

These can all take a parameter, allowing specification of the page to be operated on, instead of just the current page:

  • {{PAGENAME:Template:Main Page}}Main Page
Warning.svg
Warning: If the page title contains any parts that are "." or "..", the magic word fails returning nothing.
{{PAGENAME:one/./three}} → '. Nothing is returned.
Warning.svg
Warning: Page titles containing certain characters, such as apostrophes ' or asterisks *, may produce unexpected results when handled with these magic words, e.g. {{PAGESINCATEGORY:{{PAGENAME}}}}. See bugs T16779, T18474, T37628, T37746. One simple way to fix this is wrapping the pagename in {{#titleparts:}} from the ParserFunctions extension.

URL encoded page names[edit source]

The following are equivalents encoded for use in MediaWiki URLs (i.e. spaces replaced with underscores and some characters HTML escaped using numeric character encoding):

  • {{FULLPAGENAMEE}}
  • {{PAGENAMEE}}
  • {{BASEPAGENAMEE}}
  • {{SUBPAGENAMEE}}
  • {{SUBJECTPAGENAMEE}}
  • {{ARTICLEPAGENAMEE}}
  • {{TALKPAGENAMEE}}
  • {{ROOTPAGENAMEE}}

Note that {{PAGENAME:...}}, {{PAGENAMEE:...}} and {{urlencode:...}} have distinct implementations. See Manual:PAGENAMEE encoding for details.

Namespaces[edit source]

Variable Output Description
{{NAMESPACE}} Help Name of the page's namespace
{{NAMESPACENUMBER}} 12 ID of the page's namespace
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Help
Help
Name of the associated content namespace
{{TALKSPACE}} Help talk Name of the associated talk namespace

The following are equivalents encoded for use in MediaWiki URLs (spaces replaced with underscores and some characters percent-encoded):

  • {{NAMESPACEE}}
  • {{SUBJECTSPACEE}}
  • {{ARTICLESPACEE}}
  • {{TALKSPACEE}}

These can take a full-page-name parameter and will return the requested namespace associated with that page, instead of with the current page:

  • {{NAMESPACENUMBER:MediaWiki}}0
  • {{NAMESPACE:MediaWiki}} (Pages in main space will return empty)
  • {{NAMESPACE:Template:Main Page}}Template
  • {{SUBJECTSPACE:Template:Main Page}}Template
  • {{ARTICLESPACE:Template:Main Page}}Template
  • {{TALKSPACE:Template:Main Page}}Template talk

Parameter must not be a namespace name:

  • {{SUBJECTSPACE:Help talk}}  (Empty)

Other[edit source]

Variable Output Description
{{!}} | Used to include a pipe character as part of a template argument or table cell contents. Before this was added as a magic word, it was implemented by creating the Template:! with | as the content.

Parser functions[edit source]

Main article: Help: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 wiki includes the ParserFunctions extension which adds additional functions to those included with MediaWiki. For documentation an all the available parser functions please see Help:Parser functions.

See also[edit source]