Content deleted Content added
m Reverted edits by 187.211.0.214 (talk) to last version by Kpgjhpjm Tag: Rollback |
187.211.0.214 (talk) ←Replaced content with ' ' Tags: Replaced Mobile edit Mobile web edit |
||
Line 1: | Line 1: | ||
{{redirect|WP:MAGIC|an introduction|Help:Magic words for beginners|help on the automatic transformation of wikitext|Help:Magic|the WikiProject on stage magic and illusions|Wikipedia:WikiProject Magic}} |
|||
{{Wikipedia how-to|H:MW|WP:MAGIC}} |
|||
'''Magic words''' (including '''parser functions''', '''variables''' and '''behavior switches''') are features of [[Help:Wiki markup|wiki markup]] that give instructions to Wikipedia'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 [[WP:Templates|templates]]. |
|||
This page is a quick reference for magic words. For more information, refer to the main MediaWiki documentation: |
|||
* [[mw:Help:Magic words]]: All standard magic words, including the "standard" parser functions. |
|||
* [[mw:Help:Extension:ParserFunctions]]: Additional parser functions, including conditional expressions. |
|||
==General information== |
|||
In general, there are three types of magic words |
|||
# '''[[#Behavior switches|Behavior switches]]''': often appear in double underscores, all uppercase, e.g., <code>__NOTOC<nowiki />__</code>. They will change the behavior of a page, rather than return a value. |
|||
# '''[[#Parser functions|Parser functions]]''': all in lowercase. A parser function will be followed by colon and pipe-separated parameters, e.g., <code><nowiki>{{#ifexpr:Y|Yes|No}}</nowiki></code>, wrapped in double braces. They will take a value and return a value. |
|||
# '''[[#Variables|Variables]]''': these are all uppercase, e.g., {{tld|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]]. |
|||
* [[Whitespace character|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 [[WP:Transclusion|transcluded]], even variables "about the current page". This is ensured by the parsing order. |
|||
* Instead of magically transforming into HTML instructions, {{tag|[[help:wikitext#Nowiki|nowiki]]|o}} tags remove this magic so a magic word can itself be displayed (documented). |
|||
{{Magic<nowiki />}} words compared to {{[[Help:Template|template]]<nowiki />}}: |
|||
* As with templates, magic words can be [[help:transclusion|transcluded]] and [[Help:substitution|substituted]]. |
|||
* The names of {{magic words<nowiki />}} are purposely chosen to be unlike the names of {{templates<nowiki />}}, and vice versa. Many parser function names will begin with the # sign, but template names [[wp:NCHASHTAG | will not start with a # sign]], and probably not end in a : colon character, or be all-uppercase. |
|||
* The first parameter's syntax differs. In {{#magic: p1<nowiki />| p2 | p3}}, the name is #magic and it will be followed by an unspaced : colon and a required input parameter, p1. The first {{para|p1}} of a template is optional but would be preceded by a | pipe instead of a : colon. |
|||
==Behavior switches== |
|||
{{anchor|Behaviour switches}} |
|||
{{further|mw:Help:Magic words#Behavior switches}} |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Switch |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__TOC__</nowiki></kbd> |
|||
| Places the page's [[Help:Table of contents|table of contents (TOC)]] at the word's position. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__FORCETOC__</nowiki></kbd> |
|||
| Forces the TOC to appear in its default position. Can be used anywhere on a page. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__NOTOC__</nowiki></kbd> |
|||
| Suppresses the appearance of the page's TOC. Can be used anywhere on a page. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__NOEDITSECTION__</nowiki></kbd> |
|||
| 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 element|HTML tag]] such as {{tag|h2|content=''heading''}} rather than with the usual wiki equals-signs syntax (e.g. {{nowrap|1=<kbd>== ''heading'' ==</kbd>}}{{thinsp}}). |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__NEWSECTIONLINK__</nowiki></kbd> |
|||
| On non-talk pages, adds a "{{int:vector-action-addsection}}" link as a means to add a new section to the page. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__NONEWSECTIONLINK__</nowiki></kbd> |
|||
| Removes the "{{int:vector-action-addsection}}" link (the add-new-section link) on talk pages. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__NOGALLERY__</nowiki></kbd> |
|||
| Replaces thumbnails on a category page with normal links. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__HIDDENCAT__</nowiki></kbd> |
|||
| Makes a category [[WP:HIDDENCAT|hidden]] when included on that category's page. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__INDEX__</nowiki></kbd> |
|||
| Instructs [[Web search engine|search engine]]s to index the page. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__NOINDEX__</nowiki></kbd> |
|||
| Instructs search engines not to index the page. See [[Wikipedia:Controlling search engine indexing]]. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__STATICREDIRECT__</nowiki></kbd> |
|||
| Prevents the link on a [[Help:Redirect|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). Also instructs [[Help:Interwiki linking|interwiki]] [[Wikipedia:Bots|bots]] to treat the page as if an article. |
|||
|- |
|||
! scope="row" | <kbd><nowiki>__DISAMBIG__</nowiki></kbd> |
|||
| Marks a page as a [[WP:DAB|disambiguation page]], adds it to [[Special:DisambiguationPages]] and places inward links in [[Special:DisambiguationPageLinks]]. (See [[mw:Extension:Disambiguator]].) |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{DISPLAYTITLE:''title''}}</kbd> |
|||
| Used to amend the [[WP:DISPLAYTITLE|displayed form]] of the page's title. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{DEFAULTSORT:''sortkey''}}</kbd> |
|||
| Sets the default [[WP:SORTKEY|key]] (the index) under which the page is categorised. |
|||
|- |
|||
! scope="row" | <kbd>[[mw:Extension:Wikibase Client#noexternallanglinks|{<nowiki/>{NOEXTERNALLANGLINKS}}]]</kbd> |
|||
|| (equivalent to {<nowiki/>{NOEXTERNALLANGLINKS|*}}{{thinsp}}) Suppresses the automated inclusion of [[Wikidata:Help:Linking Wikipedia pages|Wikidata]] [[Help:Interlanguage links|interlanguage links]] on the lefthand side of the page. Links to particular rather than all languages may be suppressed by using {<nowiki/>{NOEXTERNALLANGLINKS|''list''}}, where ''list'' a [[Vertical bar|pipe]]-[[Delimiter|delimited]] list of [[language code]]s (e.g. {<nowiki/>{NOEXTERNALLANGLINKS|fr{{pipe}}es{{pipe}}ja}} to suppress the French ("fr"), Spanish ("es") and Japanese ("ja") interlanguage links). |
|||
|} |
|||
==Variables== |
|||
{{Shortcut|WP:VAR}} |
|||
{{further|mw:Help:Magic words#Variables|Wikipedia:Page name#sub}} |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Page name variable |
|||
! scope="col" | Output |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{FULLPAGENAME}}</kbd> |
|||
| {{FULLPAGENAME}} |
|||
| Canonical [[Help:page name|page name]]. ''Title line''. Title unless letter-case is altered with {{tld|DISPLAYTITLE}}. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{PAGENAME}}</kbd> |
|||
| {{PAGENAME}} |
|||
| Title line excluding [[Wikipedia:Namespace|namespace]]. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{BASEPAGENAME}}</kbd> |
|||
| {{BASEPAGENAME}} |
|||
| Title of parent page, excluding namespace. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{ROOTPAGENAME}}</kbd> |
|||
| {{ROOTPAGENAME}} |
|||
| Title of topmost parent (before all subpages), excluding namespace. |
|||
|- |
|||
! scope="row" | <kbd>[[wp:pagename#sub|{<nowiki/>{SUBPAGENAME}}]]</kbd> |
|||
| {{SUBPAGENAME}} |
|||
| On a subpage, rightmost portion of ''current'' title; higher subpagenames show as [[breadcrumb (navigation)|backlinks]]. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{ARTICLEPAGENAME}}</kbd> |
|||
| {{ARTICLEPAGENAME}} |
|||
| rowspan="2" | Title of the subject page associated with the current page. These are useful on talk pages (but see note about Category talk pages). |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{SUBJECTPAGENAME}}</kbd> |
|||
| {{SUBJECTPAGENAME}} |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{TALKPAGENAME}}</kbd> |
|||
| {{TALKPAGENAME}} |
|||
| Title of the talk page associated with the current page. Useful on subject pages. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{NAMESPACENUMBER}}</kbd> |
|||
| {{NAMESPACENUMBER:{{FULLPAGENAME}}}} |
|||
| Number of the current page's namespace. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{NAMESPACE}}</kbd> |
|||
| {{NAMESPACE}} |
|||
| Namespace of the title. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{ARTICLESPACE}}</kbd> |
|||
| {{ARTICLESPACE}} |
|||
| rowspan="2" | On a talk page, the namespace part of the title of the associated subject page. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{SUBJECTSPACE}}</kbd> |
|||
| {{SUBJECTSPACE}} |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{TALKSPACE}}</kbd> |
|||
| {{TALKSPACE}} |
|||
| Namespace of the talk page associated with the current page. |
|||
|- |
|||
! scope="row" | {{longitem|style=line-height:1.5em|<kbd>{<nowiki/>{FULLPAGENAMEE}<nowiki/>}</kbd>,<br/><kbd>{<nowiki/>{PAGENAMEE}<nowiki/>}</kbd>,<br/>{{pad|0.4em}}(etc.)}} |
|||
| {{longitem|style=line-height:1.5em|{{FULLPAGENAMEE}},<br/>{{PAGENAMEE}},<br/>(etc.)}} |
|||
| Adding an E to the end of the above variables, renders the above encoded for use in MediaWiki [[URL]]s (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 ({{thinsp}}''':'''{{thinsp}}) is used to pass the parameter, rather than a pipe ({{thinsp}}'''|'''{{thinsp}}) that is used in templates, like <kbd><nowiki>{{MAGICWORD:value}}</nowiki></kbd>. For example, <kbd><nowiki>{{TALKPAGENAME:Wikipedia:MOS}}</nowiki></kbd> returns <kbd><nowiki>Wikipedia talk:MOS</nowiki></kbd> on any page. See [[meta:Help:Page name]] for more details of parser functions. |
|||
''Note:'' |
|||
In the "Category" and "Category talk" namespaces, to wikilink (some) page name variables may require [[help:link|prefixing a colon]] to avoid unwanted categorization. |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Site variable |
|||
! scope="col" | Example |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{SITENAME}}</kbd> |
|||
| {{SITENAME}} |
|||
| |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{SERVER}}</kbd> |
|||
| {{SERVER}} |
|||
| |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{SERVERNAME}}</kbd> |
|||
| {{SERVERNAME}} |
|||
| |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{SCRIPTPATH}}</kbd> |
|||
| {{SCRIPTPATH}} |
|||
| |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{CURRENTVERSION}}</kbd> |
|||
| {{CURRENTVERSION}} |
|||
| Returns current MediaWiki version. |
|||
|} |
|||
===Other variables by type=== |
|||
{| class="wikitable" |
|||
! scope="col" | Date and time |
|||
! scope="col" | Revision data |
|||
! scope="col" | Statistics{{sup|b}} |
|||
|- style="vertical-align:top" |
|||
| |
|||
{| |
|||
| ''Universal time'' |
|||
{{startplainlist}} |
|||
* <kbd>{<nowiki/>{CURRENTYEAR}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTMONTH}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTMONTHNAME}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTMONTHABBREV}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTDAY}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTDAY2}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTDOW}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTDAYNAME}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTTIME}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTHOUR}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTWEEK}}</kbd> |
|||
* <kbd>{<nowiki/>{CURRENTTIMESTAMP}}</kbd> |
|||
{{endplainlist}} |
|||
| ''Local website time'' |
|||
{{startplainlist}} |
|||
* <kbd>{<nowiki/>{LOCALYEAR}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALMONTH}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALMONTHNAME}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALMONTHABBREV}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALDAY}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALDAY2}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALDOW}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALDAYNAME}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALTIME}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALHOUR}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALWEEK}}</kbd> |
|||
* <kbd>{<nowiki/>{LOCALTIMESTAMP}}</kbd> |
|||
{{endplainlist}} |
|||
|} |
|||
|{{startplainlist}} |
|||
* <kbd>{<nowiki/>{REVISIONID}}{{sup|a}}</kbd> |
|||
* <kbd>{<nowiki/>{REVISIONDAY}}</kbd> |
|||
* <kbd>{<nowiki/>{REVISIONDAY2}}</kbd> |
|||
* <kbd>{<nowiki/>{REVISIONMONTH}}</kbd> |
|||
* <kbd>{<nowiki/>{REVISIONYEAR}}</kbd> |
|||
* <kbd>{<nowiki/>{REVISIONTIMESTAMP}}</kbd> |
|||
* <kbd>{<nowiki/>{REVISIONUSER}}{{sup|c}}</kbd> |
|||
{{endplainlist}} |
|||
|{{startplainlist}} |
|||
* <kbd>{<nowiki/>{NUMBEROFPAGES}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFARTICLES}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFFILES}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFEDITS}}</kbd> |
|||
<!--disabled in MediaWiki (see talk page): * <kbd>{<nowiki/>{NUMBEROFVIEWS}}</kbd> |
|||
-->* <kbd>{<nowiki/>{NUMBEROFUSERS}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFADMINS}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFACTIVEUSERS}}</kbd> |
|||
{{endplainlist}} |
|||
|} |
|||
:{{sup|a}} <kbd>{<nowiki/>{REVISIONID}}</kbd> cannot be [[Wikipedia:Substitution|substituted]] and does not function in preview. |
|||
:{{sup|b}} English Wikipedia. |
|||
:{{sup|c}} This shows the last user to edit the page. There is no way to show the user viewing the page due to technical issues. |
|||
==Parser functions== |
|||
{{Shortcut|WP:PF|WP:PARSER}} |
|||
{{further|mw:Help:Magic words#Parser functions|mw:Help:Extension:ParserFunctions}} |
|||
===Metadata=== |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Function |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{PAGEID}}</kbd> |
|||
| Unique page identifier number. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{PAGESIZE:''fullpagename''}}</kbd> |
|||
| Size of named page in bytes. |
|||
|- |
|||
! scope="row" | {{anchor|PROTECTIONLEVEL}}<kbd>{<nowiki/>{PROTECTIONLEVEL:''action''{{pipe}}''fullpagename''}}</kbd> |
|||
| [[Wikipedia:Protection policy|Protection level]] assigned to ''action'' ("edit", "move", etc.) on named page. |
|||
|- |
|||
! scope="row" | {{anchor|PROTECTIONEXPIRY}}<kbd>{<nowiki/>{PROTECTIONEXPIRY:''action''{{pipe}}''fullpagename''}}</kbd> |
|||
| [[Wikipedia:Protection policy|Protection expiry]] assigned to ''action'' ("edit", "move", etc.) on named page. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{PENDINGCHANGELEVEL}}</kbd> |
|||
| Protection level for [[WP:PC|pending changes]] on the current page. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{PAGESINCATEGORY:''pagename''}}</kbd> |
|||
| Number of pages in the category named ''pagename''. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki/>{NUMBERINGROUP:''groupname''}}</kbd> |
|||
| Number of users in the [[Wikipedia:User access levels|user group]] named ''groupname''. |
|||
|} |
|||
To output numbers without comma [[Delimiter|separator]]s (for example, as "123456789" rather than "123,456,789"), append the parameter <kbd>|R</kbd>. |
|||
===Formatting=== |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Function |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd> {{((}}lc:''string''{{))}} </kbd> |
|||
| Converts all characters in ''string'' to lower case. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}lcfirst:''string''{{))}} </kbd> |
|||
| Converts first character of ''string'' to lower case. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}uc:''string''{{))}} </kbd> |
|||
| Converts all characters in ''string'' to upper case. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}ucfirst:''string''{{))}} </kbd> |
|||
| Converts first character of ''string'' to upper case. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}formatnum:''unformatted_number''{{))}}<br>{{((}}formatnum:''formatted_num'' {{pipe}}R{{))}} </kbd> |
|||
| Adds comma separators to an ''unformatted_number'' (e.g. 123456789 becomes {{formatnum:123456789}}). To remove such formatting, use <kbd>{{((}}formatnum:''formatted_number''{{pipe}}R{{))}}</kbd> (i.e. <kbd>{{braces|formatnum:7,654,321{{pipe}}R}}</kbd>, for example, produces {{formatnum:7,654,321|R}}). |
|||
|- |
|||
! scope="row" | <kbd> {{((}}#dateformat:''date''{{pipe}}''format''{{))}}<br/>{{((}}#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. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}padleft:''xyz''{{pipe}}''stringlength''{{))}} <br/> {{((}}padright:''xyz''{{pipe}}''stringlength''{{))}} <br><br> {{((}}padleft:''xyz''{{pipe}}''length''{{pipe}}''padstr''{{))}} <br/>{{((}}padright:''xyz''{{pipe}}''length''{{pipe}}''padstr''{{))}} </kbd> |
|||
| 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. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}plural:''N''{{pipe}}''singular''{{pipe}}''plural''{{))}} </kbd> |
|||
| Outputs ''singular'' if ''N'' is equal to 1, otherwise outputs ''plural''. See the [[mw:Help:Magic words#Localization|documentation at mediawiki.org]] for more details. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}#time:''format''{{pipe}}''object''{{))}} </kbd><br/> <kbd> {{((}}#timel:''format''{{pipe}}''object''{{))}} <br><br> {{((}}#time:d F Y{{pipe}}''date''{{pipe}}''langcode''{{))}} </kbd> |
|||
| Used to format dates and times, for ISO format, dots or English month names. <kbd>#timel</kbd> is based on local time as defined for each wiki; for English Wikipedia, this is identical to <kbd>#time</kbd>.<br />The optional 3rd parameter is the output language code (French, German, Swedish: fr, de, sv, etc.). Example Finnish: <kbd><nowiki>{{#time:d F Y|June 30, 2016|fi}}</nowiki></kbd> shows: {{#time:d F Y|June 30, 2016|fi}} (June). ISO to German: <kbd><nowiki>{{#time:d. M Y|1987-10-31|de}}</nowiki></kbd> shows: {{#time:d. M Y|1987-10-31|de}}.<br />For format codes, see: [[mw:Help:Extension:ParserFunctions##time]]. Use the format <kbd><nowiki>{{#time: H:i, j F Y (e)|...}}</nowiki></kbd> to match the format used by timestamps in signatures. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}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]]. |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Magic_words#Miscellaneous|{{((}}#tag:''tag''{{pipe}}''content with magic''{{))}} ]]</kbd> |
|||
| Only way to [[eval]]uate magic words ''inside a tag'', in order to generate <code><''tag''>''magic''</''tag''></code>. Also handles tag attributes. |
|||
|} |
|||
===Paths=== |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Function |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd> {{((}}localurl:''fullpagename'' {{pipe}}''query''{{))}} </kbd> |
|||
| Relative [[Path (computing)|path]] to page name. The ''query'' parameter is optional. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}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. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}canonicalurl:''fullpagename'' {{pipe}}''query''{{))}} </kbd> |
|||
| Absolute path, including protocol prefix, to page name. The ''query'' parameter is optional. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}filepath:''filename''{{))}} </kbd> |
|||
| Absolute path to the media file ''filename''. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}urlencode:''string''{{))}} </kbd> |
|||
| 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" | <kbd> {{((}}anchorencode:''string''{{))}} </kbd> |
|||
| Input encoded for use in MediaWiki URL [[Help:Anchor|section anchor]]s. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}ns:''n''{{))}} </kbd> |
|||
| Returns the name of the [[Help:Namespace|namespace]] whose index is the number ''n''. For MediaWiki URLs, use <kbd>{{((}}nse:{{))}}</kbd>. |
|||
|- |
|||
! scope="row" | <kbd>[[mw:Help:Extension:ParserFunctions##rel2abs|{{((}}#rel2abs:''path''{{))}}]] </kbd> |
|||
| Converts a relative file path to an absolute path. |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Extension:ParserFunctions##titleparts|{{((}}#titleparts:''fullpagename''{{pipe}}''number''{{pipe}}''first segment''{{))}}]]</kbd> |
|||
| Splits the fullpagename (title) into that number of segments. |
|||
|} |
|||
===Conditional=== |
|||
{{further|Help:Conditional expressions}} |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Function |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" |<kbd> [[mw:Help:Extension:Parser functions##expr|{{((}}#expr:''expression''{{))}}]] </kbd> |
|||
| Evaluates ''expression'' (see [[m:Help:Calculation]]). |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##if|{{((}}#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd> |
|||
| Outputs ''result2'' if ''string'' is [[Empty string|empty]], otherwise outputs ''result1''. |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##ifeq|{{((}}#ifeq:''string1''{{pipe}}''string2'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd> |
|||
| Outputs ''result1'' if ''string1'' and ''string2'' are equal (alphabetically or numerically), otherwise outputs ''result2''. |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##iferror|{{((}}#iferror:''test_string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd> |
|||
| Outputs ''result1'' if ''test_string'' generates a parsing error, otherwise outputs ''result2''. |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##ifexpr|{{((}}#ifexpr:''expression'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd> |
|||
| Outputs ''result1'' if ''expression''{{thinsp}} is true, otherwise outputs ''result2''. |
|||
|- |
|||
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##ifexist|{{((}}#ifexist:''pagetitle'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd> |
|||
| Outputs ''result1'' if the page [<nowiki/>[''pagetitle'']] exists, otherwise outputs ''result2''. Note that underscores are needed for spaces in namespaces. |
|||
|- |
|||
! scope="row" style="white-space: nowrap;" | <kbd> [[mw:Help:Extension:Parser functions##switch|{{((}}#switch:''string'' {{pipe}}''c1''=''r1'' {{pipe}}''c2''=''r2'' ... {{pipe}}''default''{{))}}]] </kbd> |
|||
| Outputs ''r1'' if ''string'' is ''c1'', ''r2'' if ''string'' is ''c2'', etc., otherwise outputs ''default'' (if provided). |
|||
|} |
|||
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.). |
|||
* For the use of these functions in tables, see [[Wikipedia:Conditional tables]]. |
|||
===Other=== |
|||
{| class="wikitable plainrowheaders" |
|||
! scope="col" | Function |
|||
! scope="col" | Description |
|||
|- |
|||
! scope="row" | <kbd>[[mw:Extension:Babel#Usage|{<nowiki/>{#babel:''code1''|''code2''|...}}]]</kbd> |
|||
| Render [[wp:userbox|userbox]]es telling your language skills. Improves upon {{tl|Babel}} (an alternative). |
|||
|- |
|||
! scope="row" | <kbd>[[mw:Extension:CategoryTree|{<nowiki/>{#categorytree:''category''|...}}]]</kbd> |
|||
| List pages in a category, recursively. |
|||
|- |
|||
! 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}}. |
|||
|- |
|||
! 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 [[wp:lua|lua]] template, e.g. function ''replace'' in [[Module:String#replace|module ''String'']]. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki />{[[mw:Help:Magic_words#Miscellaneous|#language]]:[[ISO_639|''code1'']]|''code2''}}</kbd> |
|||
| Print the name represented by the language code, e.g. '''en''' → '''English'''. Print in language 2 if given. |
|||
|- |
|||
! scope="row" | <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]]. |
|||
|- |
|||
! scope="row" | <kbd>[[m:Wikidata/Notes/Inclusion syntax v0.4|{<nowiki />{#property:''arg1''|''arg2''|...}} ]]</kbd> |
|||
| Include a [[d:Help:FAQ#Terminology|property]] ([[wp:Wikidata|Wikidata]]) from a named entity, instead of the default on the page. |
|||
|- |
|||
! scope="row" | <kbd>[[mw:Reading/Web/Projects/Read more|{<nowiki />{#related:...}}]]</kbd> |
|||
| Links to similar topics, to engage readers. (Beta feature.) |
|||
|- |
|||
! scope="row" | <kbd>[[Help:Labeled section transclusion|{{#section<nowiki />:}}{{zwsp}}{{#section-h<nowiki />:}}{{zwsp}}{{#section-x<nowiki />:}}]]</kbd> |
|||
| Aliases for <kbd><nowiki>{{#lst:}} {{#lsth}} {{#lstx}}</nowiki></kbd> (above). |
|||
|- |
|||
! scope="row" | <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" | <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]] |
|||
|} |
|||
==See also== |
|||
* [[Help:Magic links]] - for ISBN, PMID and RFC |
|||
* [[mw:Localisation]] |
|||
* [[mw:Manual:Extending wiki markup]] |
|||
* [https://phabricator.wikimedia.org/diffusion/MW/history/master/includes/parser/CoreParserFunctions.php CoreParserFunctions.php] |
|||
* [[User:Cacycle/wikEd|wikEd]], a MediaWiki editor with syntax highlighting for templates and parser functions |
|||
* {{myprefs|Gadgets|Editing|check=Syntax highlighter}} |
|||
* {{myprefs|Beta features|check=Wiki syntax highlighting}} |
|||
* [[Special:Version]], at the bottom of the page, all the <kbd>{<nowiki/>{magic words}}</kbd> on this page are listed there as Parser function hooks |
|||
* {{tl|Ifexist not redirect}}, works with the <nowiki>{{#ifexist:}}</nowiki> expression while allowing redirects to be identified and parsed differently |
|||
{{Wikipedia technical help|collapsed}} |
|||
[[Category:Wikipedia features]] |
|||
[[he:עזרה:משתנים]] |