Content deleted Content added
63.92.244.137 (talk) ←Blanked the page |
|||
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}} |
|||
{{shortcuts|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 == |
|||
There are three types of magic words: |
|||
{{glossary}} |
|||
{{term|1=Behavior switches|id=switches}} |
|||
{{defn|1=Uppercase words surrounded by double underscores, e.g., <kbd><nowiki>__NOTOC__</nowiki></kbd> or other keywords using parser function syntax.}} |
|||
{{term|1=Variables|id=vars}} |
|||
{{defn|1=Uppercase words surrounded by double braces (thus resembling [[Help:Template|templates]]), e.g. {{tld|PAGENAME}}.}} |
|||
{{term|1=Parser functions|id=funcs}} |
|||
{{defn|1=Keywords in double braces with parameters after a colon (some beginning with #), e.g. <kbd><nowiki>{{#expr:2+2}}</nowiki></kbd>.}} |
|||
{{end glossary}} |
|||
Some magic words are [[case sensitivity|case-insensitive]], but not all. [[Whitespace character|White space]] is stripped from the start and end of keywords and parameters, as in template syntax. |
|||
Page-dependent magic words will affect or return data about the ''current'' page, even if the word is added through a [[WP:Transclusion|transcluded]] template or included system message. |
|||
It is possible to [[Help:Substitution|substitute]] parser functions and most variables in the same way that templates are substituted (using the <kbd>subst:</kbd> keyword). This causes their current value (as evaluated at the time of substitution) to be written into the wikitext. |
|||
== 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 immediately before the page's first section (first heading). 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}} |
|||
{| class="wikitable plainrowheaders" style="clear:right" |
|||
! scope="col" | Page name variable |
|||
! scope="col" | Its output in this wikitext |
|||
! 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> |
|||
|{{startplainlist}} |
|||
* <kbd>{<nowiki/>{NUMBEROFPAGES}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFARTICLES}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFFILES}}</kbd> |
|||
* <kbd>{<nowiki/>{NUMBEROFEDITS}}</kbd> |
|||
* <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}} |
|||
{{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 [[Help:User rights|usergroup]] 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''{{))}} </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> {{((}}#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 <kbd>dmy</kbd>, <kbd>mdy</kbd>, <kbd>ymd</kbd> or <kbd>ISO 8601</kbd> formats, with the user's preference overriding the specified format. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}padleft:xyz{{pipe}}''stringlength''{{))}} </kbd><br/><kbd> {{((}}padright:xyz{{pipe}}''stringlength''{{))}} </kbd> |
|||
| Pad with zeros to the right or left; an alternative padding string can be given as a third parameter; the alternative padding string may 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> {{braces|#timel:}} </kbd> {{smaller|(for local time)}} |
|||
| Used to format dates and times. <kbd>#timel</kbd> is based on local time as defined for the entire wiki; for the English Wikipedia, where local time is set to [[Coordinated Universal Time|UTC]], this is identical to <kbd>#time</kbd>. (See [[mw:Help:Extension:ParserFunctions##time]].) |
|||
|- |
|||
! 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> {{((}}#tag:''tag''{{pipe}}''content'' {{pipe}}''p1''=''v1'' {{pipe}}''p2''=''v2''{{))}} </kbd> |
|||
| An equivalent to the HTML <kbd><''tag''>...</''tag''><kbd> that is useful when e.g. [[WP:REFNEST|nesting references]]. |
|||
|} |
|||
===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> {{((}}#expr:''expression''{{))}} </kbd> |
|||
| Evaluates ''expression'' (see [[m:Help:Calculation]]). |
|||
|- |
|||
! scope="row" | <kbd> {{((}}#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </kbd> |
|||
| Outputs ''result2'' if ''string'' is [[Empty string|empty]], otherwise outputs ''result1''. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}#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> {{((}}#iferror:''test_string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </kbd> |
|||
| Outputs ''result1'' if ''test_string'' generates a parsing error, otherwise outputs ''result2''. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}#ifexpr:''expression'' {{pipe}}''result1'' {{pipe}}''result2''{{))}} </kbd> |
|||
| Outputs ''result1'' if ''expression''{{thinsp}} is true, otherwise outputs ''result2''. |
|||
|- |
|||
! scope="row" | <kbd> {{((}}#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> {{((}}#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 the alternative, {{tl|Babel}}. |
|||
|- |
|||
! 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''|''arg2'' |...}}]]</kbd> |
|||
|| Call a ([[Wikipedia:Lua|Wikipedia-based-Lua]]) ''function'' in a [[mw:Extension:Scribunto|Scribunto]] ''module'' (e.g. [[Module:String#len|module String]]). |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki />{#language:[[m:Language_codes|''lang code 1''|''lang code 2'']]}}</kbd> |
|||
| Output the language name of the [[language code]] (e.g. en) ''in its own language'', else in language code2. |
|||
|- |
|||
! 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:Help:Extension:MassMessage#Parser_function_delivery_lists|{<nowiki />{#target:''fullpagename''}}]]</kbd> |
|||
| Send a message to a list talk pages on the fullpagename, using the [[m:MassMessage|MassMessage function]]. |
|||
|- |
|||
! scope="row" | <kbd>{<nowiki />{int:''pagename''}} </kbd> |
|||
| [[Wikipedia:Transclusion|Transclude]] a page from the [[wp:MWN|{{ns:mediawiki}} namespace]] ''interface'' according to the user's language preferences. For example, a system message. |
|||
|} |
|||
== See also == |
|||
*[[Help:Magic links]] - for ISBN, PMID and RFC |
|||
* [[mw:Localisation]] |
|||
* [[mw:Manual:Extending wiki markup]] |
|||
* [http://svn.wikimedia.org/viewvc/mediawiki/trunk/phase3/includes/parser/CoreParserFunctions.php?view=log CoreParserFunctions.php] |
|||
* [[User:Cacycle/wikEd|wikEd]], a MediaWiki editor with syntax highlighting for templates and parser functions |
|||
* {{myprefs|9|Editing|check=Syntax highlighter}} |
|||
* [[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 |
|||
{{Wikipedia technical help|collapsed}} |
|||
[[Category:Wikipedia features]] |
|||
[[he:עזרה:משתנים]] |