Difference between revisions of "Help:Magic words"

m (updating)
m (Deadfire moved page User:Deadfire/Drafts/Help:Magic words to Help:Magic words without leaving a redirect: Redo complete)
 
(One intermediate revision by the same user not shown)
Line 310: Line 310:
  
 
==Parser functions==
 
==Parser functions==
{{Shortcut|WP:PF|WP:PARSER}}
+
{{Shortcut|BTW:PF|BTW:PARSER}}
 
{{further|mw:Help:Magic words#Parser functions|mw:Help:Extension:ParserFunctions}}
 
{{further|mw:Help:Magic words#Parser functions|mw:Help:Extension:ParserFunctions}}
  
Line 325: Line 325:
 
|-
 
|-
 
! scope=row id=PROTECTIONLEVEL | <kbd>{<nowiki/>{PROTECTIONLEVEL:''action''{{pipe}}''fullpagename''}}</kbd>
 
! scope=row id=PROTECTIONLEVEL | <kbd>{<nowiki/>{PROTECTIONLEVEL:''action''{{pipe}}''fullpagename''}}</kbd>
| [[Wikipedia:Protection policy|Protection level]] assigned to ''action'' ("edit", "move", etc.) on named page (this page's protection level for "edit" is <kbd>{{PROTECTIONLEVEL:edit|Help:Magic words}}</kbd>).
+
| [[BattleTechWiki:Protection policy|Protection level]] assigned to ''action'' ("edit", "move", etc.) on named page (this page's protection level for "edit" is <kbd>{{PROTECTIONLEVEL:edit|Help:Magic words}}</kbd>).
 
|-
 
|-
 
! scope=row id=PROTECTIONEXPIRY | <kbd>{<nowiki/>{PROTECTIONEXPIRY:''action''{{pipe}}''fullpagename''}}</kbd>
 
! scope=row id=PROTECTIONEXPIRY | <kbd>{<nowiki/>{PROTECTIONEXPIRY:''action''{{pipe}}''fullpagename''}}</kbd>
| [[Wikipedia:Protection policy|Protection expiry]] assigned to ''action'' ("edit", "move", etc.) on named page (this page's protection expiry is <kbd>{{PROTECTIONEXPIRY:edit|Help:Magic words}}</kbd>).
+
| [[BattleTechWiki:Protection policy|Protection expiry]] assigned to ''action'' ("edit", "move", etc.) on named page (this page's protection expiry is <kbd>{{PROTECTIONEXPIRY:edit|Help:Magic words}}</kbd>).
|-
 
! scope=row id=PENDINGCHANGELEVEL | <kbd>{<nowiki/>{PENDINGCHANGELEVEL:''fullpagename''}}</kbd>
 
| Protection level for [[WP:PC|pending changes]] on the named page (this page, which doesn't have one, is <kbd>{{PENDINGCHANGELEVEL}}</kbd>).  
 
 
|-
 
|-
 
! scope=row id=PAGESINCATEGORY | <kbd>{<nowiki/>{PAGESINCATEGORY:''categoryname''}}</kbd>
 
! scope=row id=PAGESINCATEGORY | <kbd>{<nowiki/>{PAGESINCATEGORY:''categoryname''}}</kbd>
Line 337: Line 334:
 
|-
 
|-
 
! scope=row id=NUMBERINGROUP | <kbd>{<nowiki/>{NUMBERINGROUP:''groupname''}}</kbd>
 
! scope=row id=NUMBERINGROUP | <kbd>{<nowiki/>{NUMBERINGROUP:''groupname''}}</kbd>
| Number of users in the [[Wikipedia:User access levels|user group]] named ''groupname''.
+
| Number of users in the [[BattleTechWiki:User access levels|user group]] named ''groupname''.
 
|}
 
|}
Page IDs can be associated with articles via wikilinks (i.e. <code>[[Special:Redirect/page/3235121]]</code>goes to this page).
+
Page IDs can be associated with articles via wikilinks.
To output numbers without comma [[Delimiter|separator]]s (for example, as "123456789" rather than "123,456,789"), append the parameter <kbd>|R</kbd>.
+
To output numbers without comma [[w:Delimiter|separator]]s (for example, as "123456789" rather than "123,456,789"), append the parameter <kbd>|R</kbd>.
  
 
===Formatting===
 
===Formatting===
Line 364: Line 361:
 
|-
 
|-
 
! scope=row id=dateformat | <kbd>{<nowiki/>{#dateformat:''date''{{pipe}}''format''}}<br/>{<nowiki/>{#formatdate:''date''{{pipe}}''format''}}</kbd>
 
! scope=row id=dateformat | <kbd>{<nowiki/>{#dateformat:''date''{{pipe}}''format''}}<br/>{<nowiki/>{#formatdate:''date''{{pipe}}''format''}}</kbd>
| 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 <code>dmy</code>, <code>mdy</code>, <code>ymd</code>, or <code>[[ISO 8601]]</code> formats, with the user's preference overriding the specified 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 <code>dmy</code>, <code>mdy</code>, <code>ymd</code>, or <code>[[w:ISO 8601|ISO 8601]]</code> formats, with the user's preference overriding the specified format.
 
|-
 
|-
 
! scope=row id=padleft | <kbd>{<nowiki/>{padleft:''xyz''{{pipe}}''stringlength''}}<br/>{<nowiki/>{padright:''xyz''{{pipe}}''stringlength''}}<br><br>{<nowiki/>{padleft:''xyz''{{pipe}}''length''{{pipe}}''padstr''}}<br/>{<nowiki/>{padright:''xyz''{{pipe}}''length''{{pipe}}''padstr''}}</kbd>
 
! scope=row id=padleft | <kbd>{<nowiki/>{padleft:''xyz''{{pipe}}''stringlength''}}<br/>{<nowiki/>{padright:''xyz''{{pipe}}''stringlength''}}<br><br>{<nowiki/>{padleft:''xyz''{{pipe}}''length''{{pipe}}''padstr''}}<br/>{<nowiki/>{padright:''xyz''{{pipe}}''length''{{pipe}}''padstr''}}</kbd>
Line 376: Line 373:
 
|-
 
|-
 
! scope=row id=gender | <kbd>{<nowiki/>{gender:''user''{{pipe}}''m_out''{{pipe}}''f_out''{{pipe}}''u_out''}}</kbd>
 
! scope=row id=gender | <kbd>{<nowiki/>{gender:''user''{{pipe}}''m_out''{{pipe}}''f_out''{{pipe}}''u_out''}}</kbd>
| 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''{{thinsp}}'s preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see [[mw:Help:Magic words#gender]].
 
|-
 
|-
 
! scope=row id=mwtag | <kbd>[[mw:Help:Magic words#Miscellaneous|{<nowiki/>{#tag:''tagname''{{pipe}}''content with magic''}}]]</kbd>
 
! scope=row id=mwtag | <kbd>[[mw:Help:Magic words#Miscellaneous|{<nowiki/>{#tag:''tagname''{{pipe}}''content with magic''}}]]</kbd>
| Only way to [[eval]]uate magic words ''inside a tag'', in order to generate <code>&lt;''tagname''>''magic''&lt;/''tagname''></code>. Also handles tag attributes. Details at [[mw:Help:Magic words#tag]].
+
| Only way to [[w:eval|eval]]uate magic words ''inside a tag'', in order to generate <code>&lt;''tagname''>''magic''&lt;/''tagname''></code>. Also handles tag attributes. Details at [[mw:Help:Magic words#tag]].
 
|}
 
|}
  
Line 388: Line 385:
 
|-
 
|-
 
! scope=row id=localurl | <kbd>{<nowiki/>{localurl:''fullpagename'' {{pipe}}''query''}}</kbd>
 
! scope=row id=localurl | <kbd>{<nowiki/>{localurl:''fullpagename'' {{pipe}}''query''}}</kbd>
| Relative [[Path (computing)|path]] to page name. The ''query'' parameter is optional.
+
| Relative [[w:Path (computing)|path]] to page name. The ''query'' parameter is optional.
 
|-
 
|-
 
! scope=row id=fullurl | <kbd>{<nowiki/>{fullurl:''fullpagename'' {{pipe}}''query''}}</kbd>
 
! scope=row id=fullurl | <kbd>{<nowiki/>{fullurl:''fullpagename'' {{pipe}}''query''}}</kbd>
| Absolute path, without [[Application layer|protocol prefix]] (i.e. without "{{thinsp}}<nowiki>http:</nowiki>{{thinsp}}" etc.), to page name. The ''query'' parameter is optional.
+
| Absolute path, without [[w:Application layer|protocol prefix]] (i.e. without "{{thinsp}}<nowiki>http:</nowiki>{{thinsp}}" etc.), to page name. The ''query'' parameter is optional.
 
|-
 
|-
 
! scope=row id=canonicalurl | <kbd>{<nowiki/>{canonicalurl:''fullpagename'' {{pipe}}''query''}}</kbd>
 
! scope=row id=canonicalurl | <kbd>{<nowiki/>{canonicalurl:''fullpagename'' {{pipe}}''query''}}</kbd>
Line 400: Line 397:
 
|-
 
|-
 
! scope=row id=urlencode | <kbd>{<nowiki/>{urlencode:''string''}}</kbd>
 
! scope=row id=urlencode | <kbd>{<nowiki/>{urlencode:''string''}}</kbd>
| [[WP:ENCODE|Encodes]] ''string'' for use in URL query strings; <kbd>{{braces|urlencode:test string}}</kbd>, for example, produces: {{urlencode:test string}}. To encode ''string'' for use in URL paths or MediaWiki page names, append, respectively, {{para||PATH}} or {{para||WIKI}} (to produce "{{urlencode:test string|PATH}}" or "{{urlencode:test string|WIKI}}").
+
| Encodes ''string'' for use in URL query strings; <kbd>{{braces|urlencode:test string}}</kbd>, for example, produces: {{urlencode:test string}}. To encode ''string'' for use in URL paths or MediaWiki page names, append, respectively, {{para||PATH}} or {{para||WIKI}} (to produce "{{urlencode:test string|PATH}}" or "{{urlencode:test string|WIKI}}").
 
|-
 
|-
 
! scope=row id=anchorencode | <kbd>{<nowiki/>{anchorencode:''string''}}</kbd>
 
! scope=row id=anchorencode | <kbd>{<nowiki/>{anchorencode:''string''}}</kbd>
| Input encoded for use in MediaWiki URL [[Help:Anchor|section anchor]]s.
+
| Input encoded for use in MediaWiki URL [[Help:Link#Section_linking_(anchors)|section anchor]]s.
 
|-
 
|-
 
! scope=row id=ns | <kbd>{<nowiki/>{ns:''n''}}</kbd>
 
! scope=row id=ns | <kbd>{<nowiki/>{ns:''n''}}</kbd>
| Returns the name of the [[wp:Namespace|namespace]] whose index is the number ''n''. For MediaWiki URLs, use <kbd>{<nowiki/>{nse:}}</kbd>.
+
| Returns the name of the [[BTW:Namespace|namespace]] whose index is the number ''n''. For MediaWiki URLs, use <kbd>{<nowiki/>{nse:}}</kbd>.
 
|-
 
|-
 
! scope=row id=rel2abs | <kbd>[[mw:Help:Extension:ParserFunctions##rel2abs|{<nowiki/>{#rel2abs:''path''}}]] </kbd>
 
! scope=row id=rel2abs | <kbd>[[mw:Help:Extension:ParserFunctions##rel2abs|{<nowiki/>{#rel2abs:''path''}}]] </kbd>
Line 423: Line 420:
 
|-
 
|-
 
! scope=row id=expr |<kbd>[[mw:Help:Extension:Parser functions##expr|{<nowiki/>{#expr:''expression''}}]] </kbd>
 
! scope=row id=expr |<kbd>[[mw:Help:Extension:Parser functions##expr|{<nowiki/>{#expr:''expression''}}]] </kbd>
| Evaluates ''expression'' (see [[m:Help:Calculation]]).
+
| Evaluates ''expression'' (see [[mw:Help:Calculation]]).
 
|-
 
|-
 
! scope=row id=if | <kbd>[[mw:Help:Extension:Parser functions##if|{<nowiki/>{#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''}}]] </kbd>
 
! scope=row id=if | <kbd>[[mw:Help:Extension:Parser functions##if|{<nowiki/>{#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''}}]] </kbd>
| Outputs ''result2'' if ''string'' is [[Empty string|empty]], otherwise outputs ''result1''.
+
| Outputs ''result2'' if ''string'' is [[w:Empty string|empty]], otherwise outputs ''result1''.
 
|-
 
|-
 
! scope=row id=ifeq | <kbd>[[mw:Help:Extension:Parser functions##ifeq|{<nowiki/>{#ifeq:''string1''{{pipe}}''string2'' {{pipe}}''result1'' {{pipe}}''result2''}}]] </kbd>
 
! scope=row id=ifeq | <kbd>[[mw:Help:Extension:Parser functions##ifeq|{<nowiki/>{#ifeq:''string1''{{pipe}}''string2'' {{pipe}}''result1'' {{pipe}}''result2''}}]] </kbd>
Line 444: Line 441:
 
|}
 
|}
  
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. <kbd>{{(((}}1{{pipe}}{{)))}}</kbd>, <kbd>{{(((}}2{{pipe}}{{)))}}</kbd>, etc., rather than <kbd>{{(((}}1{{)))}}</kbd>, <kbd>{{(((}}2{{)))}}</kbd>, etc.).
+
If, in these conditional functions, [[w: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. <kbd>{{(((}}1{{pipe}}{{)))}}</kbd>, <kbd>{{(((}}2{{pipe}}{{)))}}</kbd>, etc., rather than <kbd>{{(((}}1{{)))}}</kbd>, <kbd>{{(((}}2{{)))}}</kbd>, etc.).
 
* For the use of these functions in tables, see [[Help:Conditional tables]].
 
* For the use of these functions in tables, see [[Help:Conditional tables]].
  
Line 451: Line 448:
 
! scope=col | Function
 
! scope=col | Function
 
! scope=col | Description
 
! scope=col | Description
|-
 
! scope=row id=babel | <kbd>[[mw:Extension:Babel#Usage|{<nowiki/>{#babel:''code1''|''code2''|...}}]]</kbd>
 
| Render [[Wikipedia:Userboxes|userboxes]] telling your language skills. Improves upon {{tl|Babel}} (an alternative).
 
 
|-
 
|-
 
! scope=row id=categorytree | <kbd>[[mw:Extension:CategoryTree|{<nowiki/>{#categorytree:''category''|...}}]]</kbd>
 
! scope=row id=categorytree | <kbd>[[mw:Extension:CategoryTree|{<nowiki/>{#categorytree:''category''|...}}]]</kbd>
 
| List pages in a category, recursively.
 
| List pages in a category, recursively.
 
|-
 
|-
 +
<!--
 
! scope=row | <kbd>[[mw:Extension:GeoData#Parser function|{<nowiki/>{#coordinates:''arg1''|''arg2''|...}}]]</kbd>
 
! scope=row | <kbd>[[mw:Extension:GeoData#Parser function|{<nowiki/>{#coordinates:''arg1''|''arg2''|...}}]]</kbd>
 
| Save the [[Geographic coordinate system|GeoData coordinates]] of the subject to the page's database. Used in {{tl|coord}}.
 
| Save the [[Geographic coordinate system|GeoData coordinates]] of the subject to the page's database. Used in {{tl|coord}}.
 
|-
 
|-
 +
-->
 
! scope=row style=white-space:nowrap | <kbd>[[mw:Extension:Scribunto#Usage|{<nowiki/>{#invoke:''module''|''function''|''arg1''|...}}]]</kbd>
 
! scope=row style=white-space:nowrap | <kbd>[[mw:Extension:Scribunto#Usage|{<nowiki/>{#invoke:''module''|''function''|''arg1''|...}}]]</kbd>
|| Use [[mw:Extension:Scribunto|Scribunto]] to transclude a [[Wikipedia:Lua|lua]] template, e.g. function ''replace'' in [[Module:String#replace|module ''String'']].
+
|| Use [[mw:Extension:Scribunto|Scribunto]] to transclude a [[BattleTechWiki:Lua|lua]] template, e.g. function ''replace'' in [[Module:String#replace|module ''String'']].
|-
 
! scope=row id=language | <kbd>[[mw:Help:Magic words#Miscellaneous|{<nowiki/>{#language]]:[[ISO 639|''code1''|''code2''}}]]</kbd>
 
| Print the name represented by the language code, e.g. '''en''' → '''English'''. Print in language 2 if given, e.g. <kbd><nowiki>{{#language:en|zh}}</nowiki></kbd> prints {{#language:en|zh}}
 
 
|-
 
|-
 
! scope=row id=lst | <kbd>[[mw:Extension:Labeled Section Transclusion|<nowiki>{{#lst:}}, {{#lsth:}}, {{#lstx:}}</nowiki>]]</kbd>
 
! scope=row id=lst | <kbd>[[mw:Extension:Labeled Section Transclusion|<nowiki>{{#lst:}}, {{#lsth:}}, {{#lstx:}}</nowiki>]]</kbd>
 
| Three ways to [[Help:Labeled section transclusion|transclude a section of a page]].
 
| Three ways to [[Help:Labeled section transclusion|transclude a section of a page]].
|-
 
! scope=row id=mentor | <kbd>[[Wikipedia:Growth Team features|<nowiki>{{#mentor:Username}}</nowiki>]]</kbd>
 
| Display the currently assigned mentor for target Username, if set.
 
|-
 
! scope=row id=property | <kbd>[[m:Wikidata/Notes/Inclusion syntax v0.4|{<nowiki/>{#property:''arg1''|''arg2''|...}}]]</kbd>
 
| Include a [[d:Help:FAQ#Terminology|property]] ([[Wikipedia:Wikidata|Wikidata]]) from a named entity, instead of the default on the page.
 
 
|-
 
|-
 
! scope=row id=related | <kbd>[[mw:Reading/Web/Projects/Read more|{<nowiki/>{#related:...}}]]</kbd>
 
! scope=row id=related | <kbd>[[mw:Reading/Web/Projects/Read more|{<nowiki/>{#related:...}}]]</kbd>
Line 481: Line 468:
 
! scope=row id=section | <kbd>[[Help:Labeled section transclusion|{<nowiki/>{#section:}}, {<nowiki/>{#section-h:}}, {<nowiki/>{#section-x:}}]]</kbd>
 
! scope=row id=section | <kbd>[[Help:Labeled section transclusion|{<nowiki/>{#section:}}, {<nowiki/>{#section-h:}}, {<nowiki/>{#section-x:}}]]</kbd>
 
| Aliases for <kbd><nowiki>{{#lst:}}, {{#lsth}}, {{#lstx}}</nowiki></kbd> (above).
 
| Aliases for <kbd><nowiki>{{#lst:}}, {{#lsth}}, {{#lstx}}</nowiki></kbd> (above).
|-
 
! scope=row id=statements | <kbd>[[d:Wikidata:How to use data on Wikimedia projects|{<nowiki/>{#statements:''arg1''|...}}]]</kbd>
 
| Display the value of any statement (Wikidata) included in an item.
 
|-
 
! scope=row id=target | <kbd>[[mw:Help:Extension:MassMessage#Parser function delivery lists|{<nowiki/>{#target:''fullpagename''}}]]</kbd>
 
| Send a message to a list of talk pages on the fullpagename, using the [[m:MassMessage|MassMessage function]].
 
 
|-
 
|-
 
! scope=row id=int | <kbd>[[mw:Help:Magic words#Localization|{<nowiki/>{int:''pagename''}}]] </kbd>
 
! scope=row id=int | <kbd>[[mw:Help:Magic words#Localization|{<nowiki/>{int:''pagename''}}]] </kbd>
| [[Wikipedia:Transclusion|Transclude]] an ''interface'' message, i.e. a [[Special:PrefixIndex/MediaWiki:|pagename in MediaWiki namespace]]
+
| [[BattleTechWiki:Transclusion|Transclude]] an ''interface'' message, i.e. a [[Special:PrefixIndex/MediaWiki:|pagename in MediaWiki namespace]]
 
|-
 
|-
 
! scope=row id=bang | <kbd>[[mw:Help:Magic_words#Other|{<nowiki/>{!}}]] </kbd>
 
! scope=row id=bang | <kbd>[[mw:Help:Magic_words#Other|{<nowiki/>{!}}]] </kbd>

Latest revision as of 19:19, 12 January 2024

Magic words (including parser functions, variables and behavior switches) are features of wiki markup that give instructions to BattleTechWiki's underlying MediaWiki software. For example, magic words can suppress or position the table of contents, disable indexing by external search engines, and produce output dynamically based on the current page or on user-defined conditional logic. Some of these features are especially useful for templates.

This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation:

General information[edit]

In general, there are three types of magic words.

  1. Behavior switches: often appear in double underscores, all uppercase, e.g., __NOTOC__. They will change the behavior of a page, rather than return a value.
  2. Parser functions: all in lowercase. A parser function will be followed by colon and pipe-separated parameters, e.g., {{#ifexpr:Y|Yes|No}}, wrapped in double braces. They will take a value and return a value.
  3. Variables: these are all uppercase, e.g., {{PAGENAME}}. A variable will be wrapped in double braces and will return a value in its place.

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 in template calls using named parameters).
  • 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 or hash), 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 #magicand it is followed by an unspaced :and a required input parameter, p1. With a template, p1is optional and it is preceded by a |(pipe) instead of a :, e.g. {{template|p1}}.

Behavior switches[edit]

Switch Description
__TOC__ Places the page's table of contents (TOC) at the word's position. This magic word does not work in skins that present the table of contents outside the article content e.g. the default Vector 2022 skin.
__FORCETOC__ Forces the TOC to appear in its default position, even when there are fewer than four headings. Can be used anywhere on a page. This magic word does not work in skins that present the table of contents outside the article content e.g. the default Vector 2022 skin.
__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 ==).
__ARCHIVEDTALK__ Hides the "Reply" button
__NEWSECTIONLINK__ On non-talk pages, adds a "⧼vector-action-addsection⧽" link as a means to add a new section to the page.
__NONEWSECTIONLINK__ Removes the "⧼vector-action-addsection⧽" 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 BattleTechWiki: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).
__DISAMBIG__ Marks a page as a disambiguation page, adds it to Special:DisambiguationPages and places inward links in Special:DisambiguationPageLinks. (See mw:Extension:Disambiguator.)
{{DISPLAYTITLE:title}} Used to amend the displayed form of the page's title.
{{DEFAULTSORT:sortkey}} Sets the default key (the index) under which the page is categorised.

Variables[edit]

Page name variable Output Description
{{FULLPAGENAME}} Help:Magic words Canonical page name. Title line. Title unless letter-case is altered with {{DISPLAYTITLE}}.
{{PAGENAME}} Magic words Title line excluding namespace.
{{BASEPAGENAME}} Magic words Title of parent page, excluding namespace.
{{ROOTPAGENAME}} Magic words Title of topmost parent (before all subpages), excluding namespace.
{{SUBPAGENAME}} Magic words On a subpage, rightmost portion of current title; higher subpagenames show as backlinks.
{{ARTICLEPAGENAME}} Help:Magic words Title of the subject page associated with the current page. These are useful on talk pages (but see note about Category talk pages).
{{SUBJECTPAGENAME}} Help:Magic words
{{TALKPAGENAME}} Help talk:Magic words Title of the talk page associated with the current page. Useful on subject pages.
{{NAMESPACENUMBER}} 12 Number of the current page's namespace.
{{NAMESPACE}} Help Namespace of the title.
{{ARTICLESPACE}} Help On a talk page, the namespace part of the title of the associated subject page.
{{SUBJECTSPACE}} Help
{{TALKSPACE}} Help talk Namespace of the talk page associated with the current page.
{{FULLPAGENAMEE}},
{{PAGENAMEE}},
 (etc.)
Help:Magic_words,
Magic_words,
(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:BattleTechWiki:MOS}} returns BattleTechWiki talk:MOS on any page.

Note: In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require prefixing a colon to avoid unwanted categorization.

For more details on parser functions that relate to page names and namespaces, see: meta:Help:Page name § Variables and parser functions.

Site variable Output Description
{{SITENAME}} BattleTechWiki Site name ($wgSitename).
{{SERVER}} https://www.sarna.net Domain URL ($wgServer).
{{SERVERNAME}} www.sarna.net Subdomain and domain name.
{{ARTICLEPATH}} /wiki/$1 Relative article path ($wgArticlePath).
{{SCRIPTPATH}} /wiki Relative script path ($wgScriptPath).
{{STYLEPATH}} https://cfw.sarna.net/wiki/skins Relative style path ($wgStylePath).
{{CURRENTVERSION}} 1.34.4 Returns current MediaWiki version.

Other variables by type[edit]

Current date and time
Universal time Local-website time
Variable Output Variable Output
{{CURRENTYEAR}} 2024 {{LOCALYEAR}} 2024
{{CURRENTMONTH}} 05 {{LOCALMONTH}} 05
{{CURRENTMONTHNAME}} May {{LOCALMONTHNAME}} May
{{CURRENTMONTHABBREV}} May {{LOCALMONTHABBREV}} May
{{CURRENTDAY}}[lower-alpha 1] 10 {{LOCALDAY}}[lower-alpha 1] 10
{{CURRENTDAY2}}[lower-alpha 1] 10 {{LOCALDAY2}}[lower-alpha 1] 10
{{CURRENTDOW}} 5 {{LOCALDOW}} 5
{{CURRENTDAYNAME}} Friday {{LOCALDAYNAME}} Friday
{{CURRENTTIME}} 04:54 {{LOCALTIME}} 00:54
{{CURRENTHOUR}} 04 {{LOCALHOUR}} 00
{{CURRENTWEEK}} 19 {{LOCALWEEK}} 19
{{CURRENTTIMESTAMP}}[lower-alpha 2] 20240510045444 {{LOCALTIMESTAMP}}[lower-alpha 2] 20240510005444
Page revision data
Variable Output
{{REVISIONDAY}}[lower-alpha 1] 12
{{REVISIONDAY2}}[lower-alpha 1] 12
{{REVISIONMONTH}} 01
{{REVISIONYEAR}} 2024
{{REVISIONTIMESTAMP}}[lower-alpha 2] 20240112191910
{{REVISIONUSER}}[lower-alpha 3] Deadfire
  1. 1.0 1.1 1.2 1.3 1.4 1.5 {{CURRENTDAY}}, {{LOCALDAY}} and {{REVISIONDAY}} return the day (e.g. "6"), whilst {{CURRENTDAY2}}, {{LOCALDAY2}} and {{REVISIONDAY2}} return the day with zero-padding (e.g. "06"). For all two-digit days (i.e. 10 to 31), these are the same.
  2. 2.0 2.1 2.2 These timestamp outputs can be formatted with {{Format revisiontimestamp}} (aka {{FRTS}}). For example, {{FRTS|{{REVISIONTIMESTAMP}}}} turns "20240112191910" into "2024-01-12 19:19:10".
  3. This shows the last user to edit the page. There is no way to show the user viewing the page with magic words due to technical restrictions.
Wiki statistics
{{NUMBEROFPAGES}} 134,228
{{NUMBEROFARTICLES}} 55,094
{{NUMBEROFFILES}} 20,768
{{NUMBEROFEDITS}} 1,069,040
{{NUMBEROFUSERS}} 13,815
{{NUMBEROFADMINS}} 11
{{NUMBEROFACTIVEUSERS}} 81

Parser functions[edit]

Metadata[edit]

Function Description
{{PAGEID}} Unique page identifier number (for example, this page's ID is 152385).
{{PAGESIZE:fullpagename}} Size of named page in bytes (for example, this page is 29,866 bytes).
{{PROTECTIONLEVEL:action|fullpagename}} Protection level assigned to action ("edit", "move", etc.) on named page (this page's protection level for "edit" is ).
{{PROTECTIONEXPIRY:action|fullpagename}} Protection expiry assigned to action ("edit", "move", etc.) on named page (this page's protection expiry is infinity).
{{PAGESINCATEGORY:categoryname}} Number of pages in the category named categoryname. Each subcategory is counted as one item.
{{NUMBERINGROUP:groupname}} Number of users in the user group named groupname.

Page IDs can be associated with articles via wikilinks. To output numbers without comma separators (for example, as "123456789" rather than "123,456,789"), append the parameter |R.

Formatting[edit]

Function Description
{{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}}
{{formatnum:formatted_num |R}}
R}} (i.e. {{formatnum:7,654,321|R}}, for example, produces 7654321).
{{#dateformat:date|format}}
{{#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}}

{{padleft:xyz|length|padstr}}
{{padright:xyz|length|padstr}}
Pad with zeroes '0' to the right or left, to fill the given length; an alternative padding string can be given as a third parameter; the repeated padding string (padstr) will 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:format|object}}

{{#time:d F Y|date|langcode}}
Used to format dates and times, for ISO format, dots or English month names. #timel is based on local time as defined for each wiki; for English Wikipedia, this is identical to #time.
The optional 3rd parameter is the output language code (French, German, Swedish: fr, de, sv, etc.). Example Finnish: {{#time:d F Y|June 30, 2016|fi}} shows: 30 kesäkuu 2016 (June). ISO to German: {{#time:d. M Y|1987-10-31|de}} shows: 31. Okt. 1987.
For format codes, see: mw:Help:Extension:ParserFunctions##time. Use the format {{#time: H:i, j F Y (e)|...}} to match the format used by timestamps in signatures.
{{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:tagname|content with magic}} Only way to evaluate magic words inside a tag, in order to generate <tagname>magic</tagname>. Also handles tag attributes. Details at mw:Help:Magic words#tag.

Paths[edit]

Function Description
{{localurl:fullpagename |query}} Relative path to page name. The query parameter is optional.
{{fullurl:fullpagename |query}} Absolute path, without protocol prefix (i.e. without "http:" etc.), to page name. The query parameter is optional.
{{canonicalurl:fullpagename |query}} Absolute path, including protocol prefix, to page name. The query parameter is optional.
{{filepath:filename}} Absolute path to the media file filename.
{{urlencode:string}} 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.
{{#titleparts:fullpagename|number|first segment}} Splits the fullpagename (title) into that number of segments.

Conditional[edit]

Function Description
{{#expr:expression}} Evaluates expression (see mw: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.).

Other[edit]

Function Description
{{#categorytree:category|...}} List pages in a category, recursively.
{{#invoke:module|function|arg1|...}} Use Scribunto to transclude a lua template, e.g. function replace in module String.
{{#lst:}}, {{#lsth:}}, {{#lstx:}} Three ways to transclude a section of a page.
{{#related:...}} Links to similar topics, to engage readers. (Beta feature.)
{{#section:}}, {{#section-h:}}, {{#section-x:}} Aliases for {{#lst:}}, {{#lsth}}, {{#lstx}} (above).
{{int:pagename}} Transclude an interface message, i.e. a pagename in MediaWiki namespace
{{!}} Used to include a pipe character as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creating Template:! with | as the content.
{{=}} Used to include an equal sign as part of a template argument or table cell contents. Before this was added as a magic word, many wikis implemented this by creating Template:= with = as the content.

See also[edit]