Content deleted Content added
stupid incomplete fix that i will revert Tag: Reverted |
|||
Line 15:
In general, there are three types of magic words.
# '''[[#Behavior switches|Behavior switches]]''': often appear in double underscores, all uppercase, e.g., <code>
# '''[[#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.
Line 23:
* [[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 in template calls using named parameters).
* 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), e.g. <code><nowiki><nowiki>{{#magic:}}</nowiki></nowiki></code>or <code><nowiki>{{#magic:<nowiki/>}}</nowiki></code>.
Magic words compared to templates:
* As with templates, magic words can be [[help:transclusion|transcluded]] and [[Help:substitution|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 <code>#</code>([[Hash (character)|pound or hash]]), but template names [[wp:NCHASHTAG | will not start with a <code>#</code>]], and probably not end in a <code>:</code>(colon), or be all-uppercase.
* The first parameter's syntax differs. In <code>{{#magic: <nowiki/>p1 | p2 | p3}}</code>, the name is <code>#magic</code>and it is followed by an unspaced <code>:</code>and a required input parameter, <code>p1</code>. With a template, <code>p1</code>is optional and it is preceded by a <code>|</code>(pipe) instead of a <code>:</code>, e.g. <code>{{template<nowiki/>|p1}}</code>.
Most magic words can be used in any needed locations on a page; see [[MOS:ORDER]] for guidance on where to place magic words that are behavior switches.
Line 38:
! scope=col | Description
|-
! scope=row id=TOC | <
| Places the page's [[Help:Table of contents|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.
|-
! scope=row id=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.
|-
! scope=row id=NOTOC | <
| Suppresses the appearance of the page's TOC. Can be used anywhere on a page.
|-
! scope=row id=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 element|HTML tag]] such as {{tag|h2|content=''heading''}} rather than with the usual wiki equals-signs syntax (e.g. {{nowrap|1=<
|-
! scope=row id=ARCHIVEDTALK | <
| Hides the [[:mw:Talk_pages_project/Replying|"Reply" button]]
|-
! scope=row id=NEWSECTIONLINK | <
| On non-talk pages, adds a "{{int:vector-action-addsection}}" link as a means to add a new section to the page.
|-
! scope=row id=NONEWSECTIONLINK | <
| Removes the "{{int:vector-action-addsection}}" link (the add-new-section link) on talk pages.
|-
! scope=row id=NOGALLERY | <
| Replaces thumbnails on a category page with normal links.
|-
! scope=row id=HIDDENCAT | <
| Makes a category [[WP:HIDDENCAT|hidden]] when included on that category's page.
|-
! scope=row id=INDEX | <
| Instructs [[Web search engine|search engine]]s to index the page.
|-
! scope=row id=NOINDEX | <
| Instructs search engines not to index the page. See [[Wikipedia:Controlling search engine indexing]].
|-
! scope=row id=STATICREDIRECT | <
| 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).
|-
! scope=row id=DISAMBIG | <
| 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 id=DISPLAYTITLE | <
| Used to amend the [[WP:DISPLAYTITLE|displayed form]] of the page's title.
|-
! scope=row id=DEFAULTSORT | <
| Sets the default [[Help:Category#Sorting category pages|key]] (the index) under which the page is categorised. Functionality is documented at {{section link|Help:Category#Default sort key}}, and guidelines are at {{section link|Wikipedia:Categorization#Sort keys}}.
|-
! scope=row id=NOEXTERNALLANGLINKS | <
|| (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).
|}
Line 99:
! scope=col | Description
|-
! scope=row id=FULLPAGENAME | <
| {{FULLPAGENAME}}
| Canonical [[Help:page name|page name]]. ''Title line''. Title unless letter-case is altered with {{tld|DISPLAYTITLE}}.
|-
! scope=row id=PAGENAME | <
| {{PAGENAME}}
| Title line excluding [[Wikipedia:Namespace|namespace]].
|-
! scope=row id=BASEPAGENAME | <
| {{BASEPAGENAME}}
| Title of parent page, excluding namespace.
|-
! scope=row id=ROOTPAGENAME | <
| {{ROOTPAGENAME}}
| Title of topmost parent (before all subpages), excluding namespace.
|-
! scope=row | <
| {{SUBPAGENAME}}
| On a subpage, rightmost portion of ''current'' title; higher subpagenames show as [[Breadcrumb navigation|backlinks]].
|-
! scope=row id=ARTICLEPAGENAME | <
| {{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 id=SUBJECTPAGENAME | <
| {{SUBJECTPAGENAME}}
|-
! scope=row id=TALKPAGENAME | <
| {{TALKPAGENAME}}
| Title of the talk page associated with the current page. Useful on subject pages.
|-
! scope=row id=NAMESPACENUMBER | <
| {{NAMESPACENUMBER:{{FULLPAGENAME}}}}
| Number of the current page's namespace.
|-
! scope=row id=NAMESPACE | <
| {{NAMESPACE}}
| Namespace of the title.
|-
! scope=row id=ARTICLESPACE | <
| {{ARTICLESPACE}}
| rowspan=2 | On a talk page, the namespace part of the title of the associated subject page.
|-
! scope=row id=SUBJECTSPACE | <
| {{SUBJECTSPACE}}
|-
! scope=row id=TALKSPACE | <
| {{TALKSPACE}}
| Namespace of the talk page associated with the current page.
|-
! scope=row id=FULLPAGENAMEE | {{longitem|style=line-height:1.5em|<
| {{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).
|-
! scope=row id=SHORTDESC | <
| <!-- do not invoke this magic word here: shows nothing and places page in error-tracking category -->
| Only works on the English Wikipedia, where it displays a short description below the article title on mobile platforms. {{crossref|printworthy=y|See [[Wikipedia:Short description]].}}
|}
''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 (<
''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.
Line 168:
! scope=col | Description
|-
! scope=row id=SITENAME | <
| {{SITENAME}}
| Site name ([[mw:Manual:$wgSitename|$wgSitename]]).
|-
! scope=row id=SERVER | <
| {{SERVER}}
| Domain [[URL]] ([[mw:Manual:$wgServer|$wgServer]]).
|-
! scope=row id=SERVERNAME | <
| {{SERVERNAME}}
| Subdomain and ___domain name.
|-
! scope=row id=ARTICLEPATH | <
| {{ARTICLEPATH}}
| Relative article path ([[mw:Manual:$wgArticlePath|$wgArticlePath]]).
|-
! scope=row id=SCRIPTPATH | <
| {{SCRIPTPATH}}
| Relative script path ([[mw:Manual:$wgScriptPath|$wgScriptPath]]).
|-
! scope=row id=STYLEPATH | <
| {{STYLEPATH}}
| Relative style path ([[mw:Manual:$wgStylePath|$wgStylePath]]).
|-
! scope=row id=CURRENTVERSION | <
| {{CURRENTVERSION}}
| Returns current MediaWiki version.
Line 208:
! scope=col | Output
|-
! scope=row id=CURRENTYEAR | <
| {{CURRENTYEAR}}
! scope=row id=LOCALYEAR | <
| {{LOCALYEAR}}
|-
! scope=row id=CURRENTMONTH | <
| {{CURRENTMONTH}}
! scope=row id=LOCALMONTH | <
| {{LOCALMONTH}}
|-
! scope=row id=CURRENTMONTHNAME | <
| {{CURRENTMONTHNAME}}
! scope=row id=LOCALMONTHNAME | <
| {{LOCALMONTHNAME}}
|-
! scope=row id=CURRENTMONTHABBREV | <
| {{CURRENTMONTHABBREV}}
! scope=row id=LOCALMONTHABBREV | <
| {{LOCALMONTHABBREV}}
|-
! scope=row id=CURRENTDAY | <
| {{CURRENTDAY}}
! scope=row id=LOCALDAY | <
| {{LOCALDAY}}
|-
! scope=row id=CURRENTDAY2 | <
| {{CURRENTDAY2}}
! scope=row id=LOCALDAY2 | <
| {{LOCALDAY2}}
|-
! scope=row id=CURRENTDOW | <
| {{CURRENTDOW}}
! scope=row id=LOCALDOW | <
| {{LOCALDOW}}
|-
! scope=row id=CURRENTDAYNAME | <
| {{CURRENTDAYNAME}}
! scope=row id=LOCALDAYNAME | <
| {{LOCALDAYNAME}}
|-
! scope=row id=CURRENTTIME | <
| {{CURRENTTIME}}
! scope=row id=LOCALTIME | <
| {{LOCALTIME}}
|-
! scope=row id=CURRENTHOUR | <
| {{CURRENTHOUR}}
! scope=row id=LOCALHOUR | <
| {{LOCALHOUR}}
|-
! scope=row id=CURRENTWEEK | <
| {{CURRENTWEEK}}
! scope=row id=LOCALWEEK | <
| {{LOCALWEEK}}
|-
! scope=row id=CURRENTTIMESTAMP | <
| {{CURRENTTIMESTAMP}}
! scope=row id=LOCALTIMESTAMP | <
| {{LOCALTIMESTAMP}}
|}
Line 274:
! scope=col | Output
|-
! scope=row id=REVISIONDAY | <
| {{REVISIONDAY}}
|-
! scope=row id=REVISIONDAY2 | <
| {{REVISIONDAY2}}
|-
! scope=row id=REVISIONMONTH | <
| {{REVISIONMONTH}}
|-
! scope=row id=REVISIONYEAR | <
| {{REVISIONYEAR}}
|-
! scope=row id=REVISIONTIMESTAMP | <
| {{REVISIONTIMESTAMP}}
|-
! scope=row id=REVISIONUSER | <
| {{REVISIONUSER}}
|}
Line 297:
|+ Wiki statistics
|-
! scope=row id=NUMBEROFPAGES | <
| {{NUMBEROFPAGES}}
|-
! scope=row id=NUMBEROFARTICLES | <
| {{NUMBEROFARTICLES}}
|-
! scope=row id=NUMBEROFFILES | <
| {{NUMBEROFFILES}}
|-
! scope=row id=NUMBEROFEDITS | <
| {{NUMBEROFEDITS}}
<!--disabled in MediaWiki (see talk page):
|-
! scope=row id=NUMBEROFVIEWS | <
| {{NUMBEROFVIEWS}}
-->
|-
! scope=row id=NUMBEROFUSERS | <
| {{NUMBEROFUSERS}}
|-
! scope=row id=NUMBEROFADMINS | <
| {{NUMBEROFADMINS}}
|-
! scope=row id=NUMBEROFACTIVEUSERS | <
| {{NUMBEROFACTIVEUSERS}}
|}
Line 333:
! scope=col | Description
|-
! scope=row id=PAGEID | <
| Unique page identifier number (for example, this page's ID is <samp>{{PAGEID}}</samp>).
|-
! scope=row id=PAGESIZE | <
| Size of named page in bytes (for example, this page is <samp>{{PAGESIZE:{{FULLPAGENAME}}}}</samp> bytes).
|-
! scope=row id=PROTECTIONLEVEL | <
| [[Wikipedia:Protection policy|Protection level]] assigned to ''action'' ("edit", "move", etc.) on named page (this page's protection level for "edit" is <
|-
! scope=row id=PROTECTIONEXPIRY | <
| [[Wikipedia:Protection policy|Protection expiry]] assigned to ''action'' ("edit", "move", etc.) on named page (this page's protection expiry is <
|-
! scope=row id=PENDINGCHANGELEVEL | <
| Protection level for [[WP:PC|pending changes]] on the named page (this page, which doesn't have one, is <
|-
! scope=row id=PAGESINCATEGORY | <
| Number of pages in the category named ''categoryname''. Each subcategory is counted as one item.
|-
! scope=row id=NUMBERINGROUP | <
| Number of users in the [[Wikipedia: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).
To output numbers without comma [[Delimiter|separator]]s (for example, as "123456789" rather than "123,456,789"), append the parameter <
{{cot|Magic words with other magic words as arguments, and substing}}
<syntaxhighlight
{{PAGESIZE}}
</syntaxhighlight>
{{PAGESIZE}}
<syntaxhighlight
{{PAGESIZE:Help:Magic words}}
</syntaxhighlight>
{{PAGESIZE:Help:Magic words}}
<syntaxhighlight
{{subst:PAGESIZE:Help:Magic words}}
</syntaxhighlight>
33,455
<syntaxhighlight
{{PAGESIZE:{{FULLPAGENAME}}}}
</syntaxhighlight>
{{PAGESIZE:{{FULLPAGENAME}}}}
<syntaxhighlight
{{subst:PAGESIZE:{{FULLPAGENAME}}}}
</syntaxhighlight>
0
<syntaxhighlight
{{subst:PAGESIZE:{{subst:FULLPAGENAME}}}}
</syntaxhighlight>
Line 389:
! scope=col | Description
|-
! scope=row id=lc | <
| Converts all characters in ''string'' to lower case.
|-
! scope=row id=lcfirst | <
| Converts first character of ''string'' to lower case.
|-
! scope=row id=uc | <
| Converts all characters in ''string'' to upper case.
|-
! scope=row id=ucfirst | <
| Converts first character of ''string'' to upper case.
|-
! scope=row id=formatnum | <
| Adds comma separators to an ''unformatted_number'' (e.g. 123456789 becomes {{formatnum:123456789}}). To remove such formatting, use <
|-
! scope=row id=dateformat | <
| 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 id=padleft | <
| 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 id=mwplural | <
| 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 id=mwtime | <
| Used to format dates and times, for ISO format, dots or English month names. <
|-
! scope=row id=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]] and [[translatewiki:Special:MyLanguage/Gender|translatewiki:Gender]].
|-
! scope=row id=mwtag | <
| Only way to [[eval]]uate magic words ''inside a tag'', in order to generate <code><''tagname''>''magic''</''tagname''></code>. Also handles tag attributes. Details at [[mw:Help:Magic words#tag]].
|}
Line 428:
! scope=col | Description
|-
! scope=row id=localurl | <
| Relative [[Path (computing)|path]] to page name. The ''query'' parameter is optional.
|-
! scope=row id=fullurl | <
| 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 id=canonicalurl | <
| Absolute path, including protocol prefix, to page name. The ''query'' parameter is optional.
|-
! scope=row id=filepath | <
| Absolute path to the media file ''filename''.
|-
! scope=row id=urlencode | <
| [[WP:ENCODE|Encodes]] ''string'' for use in URL query strings; <
|-
! scope=row id=anchorencode | <
| Input encoded for use in MediaWiki URL [[Help:Anchor|section anchor]]s.
|-
! scope=row id=ns | <
| Returns the name of the [[wp:Namespace|namespace]] whose index is the number ''n''. For MediaWiki URLs, use <
|-
! scope=row id=rel2abs | <
| Converts a relative file path to an absolute path.
|-
! scope=row id=titleparts | <
| Splits the fullpagename (title) into that number of segments.
|}
Line 463:
! scope=col | Description
|-
! scope=row id=expr |<
| Evaluates ''expression'' (see [[m:Help:Calculation]]).
|-
! scope=row id=if | <
| Outputs ''result2'' if ''string'' is [[Empty string|empty]], otherwise outputs ''result1''.
|-
! scope=row id=ifeq | <
| Outputs ''result1'' if ''string1'' and ''string2'' are equal (alphabetically or numerically), otherwise outputs ''result2''.
|-
! scope=row id=iferror | <
| Outputs ''result1'' if ''test_string'' generates a parsing error, otherwise outputs ''result2''.
|-
! scope=row id=ifexpr | <
| Outputs ''result1'' if ''expression''{{thinsp}} is true, otherwise outputs ''result2''.
|-
! scope=row id=ifexist | <
| 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;" | <
| 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. <
* For the use of these functions in tables, see [[Help:Conditional tables]].
Line 493:
! scope=col | Description
|-
! scope=row id=babel | <
| Render [[Wikipedia:Userboxes|userboxes]] telling your language skills. Improves upon {{tl|Babel}} (an alternative).
|-
! scope=row id=categorytree | <
| List pages in a category, recursively.
|-
! scope=row | <
| 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 | <
|| Use [[mw:Extension:Scribunto|Scribunto]] to transclude a [[Wikipedia:Lua|lua]] template, e.g. function ''replace'' in [[Module:String#replace|module ''String'']].
|-
! scope=row id=language | <
| Print the name represented by the language code, e.g. '''en''' → '''English'''. Print in language 2 if given, e.g. <
|-
! scope=row id=lst | <
| Three ways to [[Help:Labeled section transclusion|transclude a section of a page]].
|-
! scope=row id=mentor | <
| Display the currently assigned mentor for target Username, if set.
|-
! scope=row id=property | <
| 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 | <
| Links to similar topics, to engage readers. (Beta feature.)
|-
! scope=row id=section | <
| Aliases for <
|-
! scope=row id=statements | <
| Display the value of any statement (Wikidata) included in an item.
|-
! scope=row id=target | <
| Send a message to a list of talk pages on the fullpagename, using the [[m:MassMessage|MassMessage function]].
|-
! scope=row id=int | <
| [[Wikipedia:Transclusion|Transclude]] an ''interface'' message, i.e. a [[Special:PrefixIndex/MediaWiki:|pagename in MediaWiki namespace]]
|-
! scope=row id=bang | <
| 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 <code>{{!}}</code> as the content.
|-
! scope=row id=equals | <
| 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 <code>{{=}}</code> as the content.
|}
Line 547:
* {{myprefs|Beta features|check=Wiki syntax highlighting}}
* [[Special:Version]], see last section "Parser function hooks":<!--(a #section link is not possible)-->a list that should include all of the magic words on this page
* {{tl|Ifexist not redirect}}, works with the <code><nowiki>{{#ifexist:}}</nowiki></code> expression while allowing redirects to be identified and parsed differently
{{Wikipedia technical help|collapsed}}
|