Line 1: |
Line 1: |
| {{TOCRight}} | | {{TOCRight}} |
− | {{PD Help Page}}
| |
− |
| |
| | | |
| '''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 a technical reference, see {{ll|Manual:Magic words}}. | | '''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 a technical reference, see {{ll|Manual:Magic words}}. |
− |
| |
| | | |
| There are three general types of magic words: | | There are three general types of magic words: |
− |
| |
| | | |
| * '''[[#Behavior switches|Behavior switches]]''': these are usually written as uppercase words surrounded by double underscores, ''e.g.'' '''<code>__FOO__</code>'''. | | * '''[[#Behavior switches|Behavior switches]]''': these are usually written as uppercase words surrounded by double underscores, ''e.g.'' '''<code>__FOO__</code>'''. |
− |
| |
− |
| |
| * '''[[#Variables|Variables]]''': these are uppercase words surrounded by double braces, ''e.g.'' '''<code><nowiki>{{FOO}}</nowiki></code>'''. As such, they look a lot like [[Special:MyLanguage/Help:Templates|templates]]. | | * '''[[#Variables|Variables]]''': these are uppercase words surrounded by double braces, ''e.g.'' '''<code><nowiki>{{FOO}}</nowiki></code>'''. As such, they look a lot like [[Special:MyLanguage/Help:Templates|templates]]. |
− |
| |
− |
| |
| * '''[[#Parser functions|Parser functions]]''': these take parameters and are either of the form'''<code><nowiki>{{foo:...}}</nowiki></code>''' '''<code><nowiki>{{#foo:...}}</nowiki></code>''', e.g. <code><nowiki>{{#invoke:}}</nowiki></code>. See also {{ll|Help:Extension:ParserFunctions}} and {{ll|Extension:Scribunto}}. | | * '''[[#Parser functions|Parser functions]]''': these take parameters and are either of the form'''<code><nowiki>{{foo:...}}</nowiki></code>''' '''<code><nowiki>{{#foo:...}}</nowiki></code>''', e.g. <code><nowiki>{{#invoke:}}</nowiki></code>. See also {{ll|Help:Extension:ParserFunctions}} and {{ll|Extension:Scribunto}}. |
− |
| |
| | | |
| Variables and parser functions can use [[Special:MyLanguage/Manual:subst|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. | | Variables and parser functions can use [[Special:MyLanguage/Manual:subst|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. |
− |
| |
| {{anchor|Behavior switches}} | | {{anchor|Behavior switches}} |
− |
| |
| == Behavior switches == | | == Behavior switches == |
− |
| |
− |
| |
| 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. Notably some of these are not supported by the [[Skin:MinervaNeue|Minerva skin]]. | | 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. Notably some of these are not supported by the [[Skin:MinervaNeue|Minerva skin]]. |
− |
| |
| {| class="wikitable" | | {| class="wikitable" |
| |- | | |- |
Line 88: |
Line 74: |
| |- | | |- |
| | colspan="2" | <code><nowiki>__START__</nowiki></code> | | | colspan="2" | <code><nowiki>__START__</nowiki></code> |
− | | No effect. Was used to point where database message starts after comment that should not be transcluded. <small> Removed in <tvar|1>{{rev|1695}} and completely removed in {{rev|24784}}</small> | + | | No effect. Was used to point where database message starts after comment that should not be transcluded. <small> Removed in {{rev|1695}} and completely removed in {{rev|24784}}</small> |
| | {{MW version|version=1.10|compact=y|comment=and before|r=1610}} | | | {{MW version|version=1.10|compact=y|comment=and before|r=1610}} |
| |- | | |- |
| | colspan="2" | <code><nowiki>__END__</nowiki></code> | | | colspan="2" | <code><nowiki>__END__</nowiki></code> |
− | | Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace. Removed in <tvar|1>[[rev:19213|19213]]. | + | | Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace. Removed in [[rev:19213|19213]]. |
| | {{MW version|version=1.1|compact=y|version2=1.8}} | | | {{MW version|version=1.1|compact=y|version2=1.8}} |
| |- | | |- |
Line 124: |
Line 110: |
| | {{MW version|version=1.21|compact=y|comment=and after|r=}} | | | {{MW version|version=1.21|compact=y|comment=and after|r=}} |
| |} | | |} |
− |
| |
| {{anchor|Variables}} | | {{anchor|Variables}} |
| | | |
| == Variables == | | == Variables == |
− |
| |
− |
| |
| Variables return information about the current page, wiki, or date. Their syntax is similar to [[<tvar|help-templates>Special:MyLanguage/Help:Templates|templates]]. Variables marked as "<span style="background: #FED;">'''[expensive]'''</span>" are tracked by the software, and the number that can be included on a page is limited. | | Variables return information about the current page, wiki, or date. Their syntax is similar to [[<tvar|help-templates>Special:MyLanguage/Help:Templates|templates]]. Variables marked as "<span style="background: #FED;">'''[expensive]'''</span>" 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 [[{{ns:10}}:PAGENAME]] you would need to write <tvar|code><code><nowiki>{{</nowiki>{{ns:10}}:PAGENAME<tvar|code-end><nowiki>}}</nowiki></code>). In some cases, adding parameters will force the parser to invoke a template; for example, <tvar|tpl-currentdayname-code><code><nowiki>{{CURRENTDAYNAME|x}}</nowiki></code> transcludes <tvar|tpl-currentdayname-result>[[{{ns:10}}:CURRENTDAYNAME]], ''not'' the variable. | | If a template name conflicts with a variable, the variable will be used (so to transclude the template [[{{ns:10}}:PAGENAME]] you would need to write <tvar|code><code><nowiki>{{</nowiki>{{ns:10}}:PAGENAME<tvar|code-end><nowiki>}}</nowiki></code>). In some cases, adding parameters will force the parser to invoke a template; for example, <tvar|tpl-currentdayname-code><code><nowiki>{{CURRENTDAYNAME|x}}</nowiki></code> transcludes <tvar|tpl-currentdayname-result>[[{{ns:10}}:CURRENTDAYNAME]], ''not'' the variable. |
− |
| |
− |
| |
| {{anchor|Date and time}} | | {{anchor|Date and time}} |
− |
| |
| === Date and time === | | === Date and time === |
− |
| |
| | | |
| The following variables return the current date and time in [[w:UTC|UTC]]. | | The following variables return the current date and time in [[w:UTC|UTC]]. |
− |
| |
| | | |
| Due to MediaWiki and browser caching, these variables frequently show when the page was ''cached'' rather than the current time. | | 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 <tvar|MagicWordFactory>[https://github.com/wikimedia/mediawiki/blob/master/includes/MagicWordFactory.php#L122 MagicWordFactory]. | | The use of those variables cause pages to be cached for a more limited number of seconds. This is configured in <tvar|MagicWordFactory>[https://github.com/wikimedia/mediawiki/blob/master/includes/MagicWordFactory.php#L122 MagicWordFactory]. |
− |
| |
| | | |
| The date and time magic words are formatted in the wiki content language. Since {{r|94680|1.19}}, they depend on the [[<tvar|manual-pagelang>Special:MyLanguage/Manual:Language#page-content-lang|page content language]]. | | The date and time magic words are formatted in the wiki content language. Since {{r|94680|1.19}}, they depend on the [[<tvar|manual-pagelang>Special:MyLanguage/Manual:Language#page-content-lang|page content language]]. |
− |
| |
| {| class="wikitable" | | {| class="wikitable" |
| ! Variable | | ! Variable |
Line 238: |
Line 212: |
| | {{MW version|version=1.7|compact=y|comment=and after}} | | | {{MW version|version=1.7|compact=y|comment=and after}} |
| |} | | |} |
− |
| |
| | | |
| | | |
| The following variables do the same as the preceding ones but using the site's server config or <tvar|manual-wg-localtimezone>{{mediawiki|Special:MyLanguage/Manual:$wgLocaltimezone|$wgLocaltimezone}}. | | The following variables do the same as the preceding ones but using the site's server config or <tvar|manual-wg-localtimezone>{{mediawiki|Special:MyLanguage/Manual:$wgLocaltimezone|$wgLocaltimezone}}. |
− |
| |
| | | |
| * <code><nowiki>{{LOCALYEAR}}</nowiki></code> | | * <code><nowiki>{{LOCALYEAR}}</nowiki></code> |
Line 258: |
Line 230: |
| * <code><nowiki>{{LOCALWEEK}}</nowiki></code> | | * <code><nowiki>{{LOCALWEEK}}</nowiki></code> |
| * <code><nowiki>{{LOCALTIMESTAMP}}</nowiki></code> | | * <code><nowiki>{{LOCALTIMESTAMP}}</nowiki></code> |
− |
| |
− |
| |
| | | |
| ''For more thorough time formatting, or to output the current year and week with better compliance with [[wikipedia:ISO-8601|ISO-8601]], you may want to install <tvar|ext-parserfunctions>{{ll|Extension:ParserFunctions}} to use the [[<tvar|ext-parserfunct-t>Special:MyLanguage/Help:Extension:ParserFunctions#.23time|#time parser function]]''. | | ''For more thorough time formatting, or to output the current year and week with better compliance with [[wikipedia:ISO-8601|ISO-8601]], you may want to install <tvar|ext-parserfunctions>{{ll|Extension:ParserFunctions}} to use the [[<tvar|ext-parserfunct-t>Special:MyLanguage/Help:Extension:ParserFunctions#.23time|#time parser function]]''. |
| | | |
| === Technical metadata === | | === Technical metadata === |
− |
| |
| | | |
| ''Note:'' Revision variables return data about the '''latest edit to the current page''', even if viewing an older version of the page. | | ''Note:'' Revision variables return data about the '''latest edit to the current page''', even if viewing an older version of the page. |
Line 324: |
Line 293: |
| | <code><nowiki>{{PAGEID}}</nowiki></code> | | | <code><nowiki>{{PAGEID}}</nowiki></code> |
| | {{PAGEID}} | | | {{PAGEID}} |
− | | Returns the [[<tvar|1>Special:MyLanguage/Manual:Page table#page_id|page identifier]]. | + | | Returns the [[Special:MyLanguage/Manual:Page table#page_id|page identifier]]. |
| | {{MW version|version=1.20|compact=y|comment=and after|gerrit change=9858}} | | | {{MW version|version=1.20|compact=y|comment=and after|gerrit change=9858}} |
| |- | | |- |
Line 353: |
Line 322: |
| | <code><nowiki>{{REVISIONID}}</nowiki></code> | | | <code><nowiki>{{REVISIONID}}</nowiki></code> |
| | {{REVISIONID}} | | | {{REVISIONID}} |
− | | Unique revision ID. It is empty in preview, thus one can show an error message only in preview. May be disabled in [[<tvar|1>Special:MyLanguage/Manual:$wgMiserMode|miser mode]]. | + | | Unique revision ID. It is empty in preview, thus one can show an error message only in preview. May be disabled in [[Special:MyLanguage/Manual:$wgMiserMode|miser mode]]. |
| | {{MW version|version=1.5|compact=y|comment=and after}} | | | {{MW version|version=1.5|compact=y|comment=and after}} |
| |- | | |- |
Line 368: |
Line 337: |
| | <code><nowiki>{{REVISIONMONTH}}</nowiki></code> | | | <code><nowiki>{{REVISIONMONTH}}</nowiki></code> |
| | {{REVISIONMONTH}} | | | {{REVISIONMONTH}} |
− | | Month edit was made (zero-padded number as of <tvar|1>[[rev:66200|1.17+]], unpadded number in prior versions). | + | | Month edit was made (zero-padded number as of [[rev:66200|1.17+]], unpadded number in prior versions). |
| | {{MW version|version=1.8|compact=y|comment=and after}} | | | {{MW version|version=1.8|compact=y|comment=and after}} |
| |- | | |- |
Line 417: |
Line 386: |
| ( for noerror and noreplace) | | ( for noerror and noreplace) |
| |} | | |} |
− |
| |
| | | |
| === Statistics === | | === Statistics === |
− |
| |
| | | |
| 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, <tvar|nop-code><code><nowiki>{{NUMBEROFPAGES}}</nowiki></code> → <tvar|nop-result>{{NUMBEROFPAGES}} and <tvar|nop-r-code><code><nowiki>{{NUMBEROFPAGES:R}}</nowiki></code> → <tvar|nop-r-result>{{NUMBEROFPAGES:R}}). | | 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, <tvar|nop-code><code><nowiki>{{NUMBEROFPAGES}}</nowiki></code> → <tvar|nop-result>{{NUMBEROFPAGES}} and <tvar|nop-r-code><code><nowiki>{{NUMBEROFPAGES:R}}</nowiki></code> → <tvar|nop-r-result>{{NUMBEROFPAGES:R}}). |
− |
| |
| | | |
| Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example <tvar|pic><code><nowiki>{{PAGESINCATEGORY:Help}}</nowiki></code> and <tvar|pic-r><code><nowiki>{{PAGESINCATEGORY:Help|R}}</nowiki></code>, or <tvar|pic-subcats><code><nowiki>{{PAGESINCATEGORY:Help|subcats}}</nowiki></code> and <tvar|pic-subcats-r><code><nowiki>{{PAGESINCATEGORY:Help|subcats|R}}</nowiki></code>). Also applicable to <tvar|pagesize><code><nowiki>{{PAGESIZE:</nowiki>''page name''<tvar|pagesize-end><nowiki>}}</nowiki></code> hereinbefore. | | Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example <tvar|pic><code><nowiki>{{PAGESINCATEGORY:Help}}</nowiki></code> and <tvar|pic-r><code><nowiki>{{PAGESINCATEGORY:Help|R}}</nowiki></code>, or <tvar|pic-subcats><code><nowiki>{{PAGESINCATEGORY:Help|subcats}}</nowiki></code> and <tvar|pic-subcats-r><code><nowiki>{{PAGESINCATEGORY:Help|subcats|R}}</nowiki></code>). Also applicable to <tvar|pagesize><code><nowiki>{{PAGESIZE:</nowiki>''page name''<tvar|pagesize-end><nowiki>}}</nowiki></code> hereinbefore. |
− |
| |
| | | |
| The number magic words are formatted in the wiki content language. Since {{r|94680|1.19}}, it depends on the [[<tvar|manual-pagelang>Special:MyLanguage/Manual:Language#page-content-lang|page content language]]. | | The number magic words are formatted in the wiki content language. Since {{r|94680|1.19}}, it depends on the [[<tvar|manual-pagelang>Special:MyLanguage/Manual:Language#page-content-lang|page content language]]. |
Line 444: |
Line 409: |
| | <code><nowiki>{{NUMBEROFARTICLES}}</nowiki></code> | | | <code><nowiki>{{NUMBEROFARTICLES}}</nowiki></code> |
| | {{NUMBEROFARTICLES}} | | | {{NUMBEROFARTICLES}} |
− | | {{Anchor|NUMBEROFARTICLES}} Number of pages in {{<tvar|1>mediawiki|Special:MyLanguage/Manual:Using custom namespaces#content-ns|content namespaces}} that qualify as articles. See <tvar|1>{{ll|Manual:$wgArticleCountMethod}} for details. | + | | {{Anchor|NUMBEROFARTICLES}} Number of pages in {{mediawiki|Special:MyLanguage/Manual:Using custom namespaces#content-ns|content namespaces}} that qualify as articles. See {{ll|Manual:$wgArticleCountMethod}} for details. |
| | | | | |
| |- | | |- |
Line 563: |
Line 528: |
| | | |
| | | |
− | As of <tvar|1>[[rev:46662|1.15+]], these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page: | + | As of [[rev:46662|1.15+]], these can all take a parameter, allowing specification of the page to be operated on, instead of just the current page: |
| | | |
| * <code><nowiki>{{PAGENAME:Template:Main Page}}</nowiki></code> → '''{{PAGENAME:Template:Main Page}}''' | | * <code><nowiki>{{PAGENAME:Template:Main Page}}</nowiki></code> → '''{{PAGENAME:Template:Main Page}}''' |
Line 572: |
Line 537: |
| }} | | }} |
| | | |
− | {{Warning|1= Page titles containing certain characters, such as apostrophes <code>'</code> or asterisks <code>*</code>, may produce unexpected results when handled with these magic words, e.g. <tvar|pic><code><nowiki>{{PAGESINCATEGORY:{{PAGENAME}}}}</nowiki></code>. See bugs <tvar|1>[[phabricator:T16779|T16779]], [[phabricator:T18474|T18474]], [[phabricator:T37628|T37628]], [[phabricator:T37746|T37746]]. One simple way to fix this is wrapping the pagename in <tvar|titleparts><code><nowiki>{{</nowiki>[[Special:MyLanguage/Help:Extension:ParserFunctions#.23titleparts|#titleparts:]]<nowiki>}}</nowiki></code> from the [[<tvar|help-ext-pf>Special:MyLanguage/Help:Extension:ParserFunctions|ParserFunctions extension]]. | + | {{Warning|1= Page titles containing certain characters, such as apostrophes <code>'</code> or asterisks <code>*</code>, may produce unexpected results when handled with these magic words, e.g. <tvar|pic><code><nowiki>{{PAGESINCATEGORY:{{PAGENAME}}}}</nowiki></code>. See bugs [[phabricator:T16779|T16779]], [[phabricator:T18474|T18474]], [[phabricator:T37628|T37628]], [[phabricator:T37746|T37746]]. One simple way to fix this is wrapping the pagename in <tvar|titleparts><code><nowiki>{{</nowiki>[[Special:MyLanguage/Help:Extension:ParserFunctions#.23titleparts|#titleparts:]]<nowiki>}}</nowiki></code> from the [[<tvar|help-ext-pf>Special:MyLanguage/Help:Extension:ParserFunctions|ParserFunctions extension]]. |
| }} | | }} |
| | | |
Line 641: |
Line 606: |
| | | |
| | | |
− | As of <tvar|1>[[rev:46630|1.15+]], these can take a full-page-name parameter and will return the requested namespace associated with that page, instead of with the current page: | + | As of [[rev:46630|1.15+]], these can take a full-page-name parameter and will return the requested namespace associated with that page, instead of with the current page: |
| | | |
| | | |
Line 733: |
Line 698: |
| | <code><nowiki>{{REVISIONMONTH: </nowiki> ''page name''<nowiki> }}</nowiki></code> | | | <code><nowiki>{{REVISIONMONTH: </nowiki> ''page name''<nowiki> }}</nowiki></code> |
| | {{REVISIONMONTH: MediaWiki }} | | | {{REVISIONMONTH: MediaWiki }} |
− | | '''[ Expensive]''' Month of edit from the last revision of the specified page* (zero-padded number as of <tvar|1>[[rev:66200|1.17+]], unpadded number in prior versions). | + | | '''[ Expensive]''' Month of edit from the last revision of the specified page* (zero-padded number as of [[rev:66200|1.17+]], unpadded number in prior versions). |
| | {{MW version|version=1.23|compact=y|comment=and after|gerrit change=76534}}{{Anchor|REVISIONMONTH1:}} | | | {{MW version|version=1.23|compact=y|comment=and after|gerrit change=76534}}{{Anchor|REVISIONMONTH1:}} |
| |- style="background: #FED;" | | |- style="background: #FED;" |
Line 802: |
Line 767: |
| <code><nowiki>{{filepath:Example.svg|300}}</nowiki></code><br />→ {{filepath:Example.svg|300}} <br /><br /> | | <code><nowiki>{{filepath:Example.svg|300}}</nowiki></code><br />→ {{filepath:Example.svg|300}} <br /><br /> |
| The parameter <code>nowiki</code> usually removes the link around the filepath (which can't be seen in this example). | | The parameter <code>nowiki</code> usually removes the link around the filepath (which can't be seen in this example). |
− | | A protocol-relative path to the full size or thumbnail (<tvar|1>[[rev:80813|1.18+]]) of a media file. | + | | A protocol-relative path to the full size or thumbnail ([[rev:80813|1.18+]]) of a media file. |
| | {{MW version|version=1.12|compact=y|comment=and after|r=25854}} <br />{{MW version|version=1.18|compact=y|comment=and after|r=80813}} | | | {{MW version|version=1.12|compact=y|comment=and after|r=25854}} <br />{{MW version|version=1.18|compact=y|comment=and after|r=80813}} |
| |- | | |- |
Line 1,007: |
Line 972: |
| | | |
| | | |
− | '''[[<tvar|1>bugzilla:16852|Bug]] (fixed in [[rev:45734|r45734]]):''' multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters. | + | '''[[bugzilla:16852|Bug]] (fixed in [[rev:45734|r45734]]):''' multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters. |
| | {{MW version|version=1.8|compact=y|comment=and after}} | | | {{MW version|version=1.8|compact=y|comment=and after}} |
| |- | | |- |
Line 1,104: |
Line 1,069: |
| | <code><nowiki>{{int:xyz}}</nowiki></code> | | | <code><nowiki>{{int:xyz}}</nowiki></code> |
| | | | | |
− | | Same as <tvar|mw><nowiki>{{MediaWiki:xyz}}</nowiki>, except standard message translation is applied depending on subpages and content/user/uselang language. Another difference is: this doesn't appear under "<tvar|translatesused>{{int|templatesused}}". Rendered as <tvar|int>{{int:xyz}} if <tvar|mw>[[MediaWiki:xyz]] doesn't exist. See also <tvar|1>{{ll|Help:System message}}. | + | | Same as <tvar|mw><nowiki>{{MediaWiki:xyz}}</nowiki>, except standard message translation is applied depending on subpages and content/user/uselang language. Another difference is: this doesn't appear under "<tvar|translatesused>{{int|templatesused}}". Rendered as <tvar|int>{{int:xyz}} if <tvar|mw>[[MediaWiki:xyz]] doesn't exist. See also {{ll|Help:System message}}. |
| | | | | |
| |- | | |- |
Line 1,129: |
Line 1,094: |
| | <code><nowiki>{{safesubst:xyz}}</nowiki></code> | | | <code><nowiki>{{safesubst:xyz}}</nowiki></code> |
| | | | | |
− | | See <tvar|1>{{ll|Help:Template#Usage}}. | + | | See {{ll|Help:Template#Usage}}. |
| | | | | |
| |} | | |} |