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 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 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]]. |