Difference between revisions of "Help:Magic words"

From SacredWiki
Jump to navigation Jump to search
m (1 revision(s))
 
m (1 revision: Updating our Help Pages)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{PD Help Page}}
+
{{Notice|1=
 +
See '''[[mw:Help:Magic words|Help:Magic words]] on [[mw:|www.mediawiki.org]]''' for more magic words in the MediaWiki software. The page here is currently kept for things not yet merged to www.mediawiki.org and for documentation specific to the Wikimedia Foundation. If something is missing from both pages, check the [//meta.wikimedia.org/w/index.php?title=Help:Magic_words&oldid=3392669 full version of this page] and restore the lacking information.
 +
}}
  
'''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 is about usage of standard magic words; for a technical reference, see {{mediawiki|Manual:Magic words}}.
+
{{H:h|editor toc}}
  
==General notes==
+
This is an organized index of magic words used in MediaWiki.
* '''Inheritance:''' page-dependent magic words will affect or return data about the current page, regardless of whether it is in the page code or a transcluded template.
 
  
==Behaviour switches==
+
A "'''[[w:Magic (programming)|magic]] word'''" is a symbol recognized by the MediaWiki software and which when seen in the non-commented text of the page, triggers the software to do something other than display that symbol, or transclude a page with that name, but instead to use the symbol directly.  
A behaviour switch controls the layout or behaviour of the page and can often be used to specify desired omissions and inclusions in the content. They are usually written as an upercase word wrapped with double underscores.
 
  
{| {{prettytable}}
+
A magic word can be:
|-
+
* a behavior switch, called using an upper case word, preceded and followed by pairs of underscores, e.g. '''<nowiki>__NOTOC__</nowiki>'''
!{{Hl2}}| Word
+
* [[Help:XML-style tags|XML-style tags]], preceded by "<" (and for the end tag "/") and followed by ">", as in '''&lt;nowiki>'''...'''&lt;/nowiki>'''
!{{Hl2}}| Description
+
* a [[help:parser function|parser function]]: similar to a template, a word preceded by the symbols "'''<nowiki>{{</nowiki>'''" and followed by "'''<nowiki>}}</nowiki>'''", and optionally parameter definitions between pipe characters, except that the part before the first pipe (or without pipes, the text between the braces) contains a colon ("''':'''"), e.g. <nowiki>{{</nowiki>'''ns:'''3}} and {{'''#ifexpr:'''<nowiki>{{{1}}}>3|large|small}}</nowiki>
!{{Hl2}}| Versions
+
* a [[help:variable|variable]]: similar to a template without parameters, a word preceded by the symbols "'''<nowiki>{{</nowiki>'''" and followed by "'''<nowiki>}}</nowiki>'''", except the word used is in all upper case, e.g. '''<nowiki>{{CURRENTDAY}}</nowiki>''' 
|-
+
* a template modifier
|{{Hl3}} colspan="3"| '''Table of contents'''
+
* an image modifier
|-
+
 
| <nowiki>__NOTOC__</nowiki>
+
If a page in the template namespace has the same name as a magic word, the magic word will be invoked instead.  If you discover you absolutely have to define a template with the same name as a magic word, prefix the name of the template with "'''msg:'''" or the name of the template namespace ("'''Template:'''").  See below for further details if you need this feature.
| Hides the table of contents (TOC).
+
 
|
+
== Variables ==
|-
+
 
|<nowiki>__FORCETOC__</nowiki>
+
:''For details see [[Help:Variable]]''
| Forces the table of content to appear at its normal position (above the first header).
+
 
|
+
=== Page names and related info ===
|-
+
{{H:Page name variables}}
| <nowiki>__TOC__</nowiki>
+
 
| Places a table of contents at the word's current position (overriding <nowiki>__NOTOC__</nowiki>). If this is used multiple times, the table of contents will appear at the first word's position.
+
== Template modifiers ==
|
+
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
|-
+
! Usage
|{{Hl3}} colspan="3"| '''Editing'''
+
! Explanation
|-
 
| <nowiki>__NOEDITSECTION__</nowiki>
 
| Hides the section edit links beside headings.
 
|
 
|-
 
| <nowiki>__NEWSECTIONLINK__</nowiki>
 
| Adds a link (([[MediaWiki:Addsection|"+" by default]]) beside the "edit" tab for adding a new section on a non-talk page (see {{mediawiki|m:Help:Section#Adding a section at the end|Adding a section to the end}}).
 
| 1.7+
 
|-
 
|{{Hl3}} colspan="3"| '''Categories'''
 
|-
 
| <nowiki>__NOGALLERY__</nowiki>
 
| Used on a category page, replaces thumbnails in the category view with normal links.
 
| 1.7+
 
|-
 
| <nowiki>__HIDDENCAT__</nowiki>
 
| Used on a category page, hides the category from the lists of categories in its members and parent categories (there is an option in the [[Help:Preferences|user preferences]] to show them).
 
| 1.13+
 
|-
 
| <nowiki>{{DEFAULTSORT:xyz}}</nowiki>
 
| Used on a categorized page, sets a default [[Help:Categories|category sort key]].
 
| 1.10+
 
|-
 
|{{Hl3}} colspan="3"| '''Language conversion'''
 
|-
 
| <nowiki>__NOCONTENTCONVERT__</nowiki><br /><nowiki>__NOCC__</nowiki>
 
| On wikis with language variants, don't perform any content language conversion (character and phase) in article display; for example, only show Chinese (zh) instead of variants like zh_cn, zh_tw, zh_sg, or zh_hk.
 
|
 
|-
 
| <nowiki>__NOTITLECONVERT__</nowiki><br /><nowiki>__NOTC__</nowiki>
 
| On wikis with language variants, don't perform language conversion on the title (all other content is converted).
 
|
 
|-
 
|{{Hl3}} colspan="3"| '''Page formatting'''
 
|-
 
| <nowiki>{{DISPLAYTITLE:xyz}}</nowiki>
 
| Format the current page's title header. The value must be equivalent to the default title: only capitalization changes and replacing spaces with underscores. It can be disabled or enabled by {{mediawiki|Manual:$wgAllowDisplayTitle|$wgAllowDisplayTitle}}; disabled by default before 1.10+, enabled by default thereafter.
 
| 1.7+
 
 
|-
 
|-
| <nowiki>__END__</nowiki>
+
| <nowiki>{{:xyz}}</nowiki>
| Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace. Removed in {{mediawiki|rev:19213|19213}}.
+
| A bare colon is not a template modifier, it's the prefix for the main namespace. Test e.g. article {&#123;:UTC&#125;} vs. template {&#123;UTC&#125;}.<br>Using this syntax you include the text of the main namespace article xyz in another article.
|
 
 
|-
 
|-
|{{Hl3}} colspan="3"| '''Other'''
+
| <nowiki>{{int:xyz}}</nowiki>
 +
| Same as <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 "{{int:templatesused}}". Rendered as {{int:xyz}} if [[MediaWiki:xyz]] doesn't exist. See also [[Help:System message]].
 
|-
 
|-
| <nowiki>__START__</nowiki>
+
| <nowiki>{{msg:xyz}}</nowiki>
| No effect.
+
| Even if there is a magic word named "xyz", use template:xyz unless the template doesn't exist (equivalent to <nowiki>{{template:xyz}}</nowiki>). Normally, magic words have priority when there is a conflict.
|
 
|-
 
<nowiki>__NOINDEX__</nowiki>
 
| Tell search engines not to index the page (ie, do not list in search engines' results).
 
| {{mediawiki|rev:37973|1.13+}}
 
 
|-
 
|-
| <nowiki>__INDEX__</nowiki>
+
| <nowiki>{{msgnw:xyz}}</nowiki>
| Tell search engines to index the page (overrides {{mediawiki|Manual:$wgArticleRobotPolicies|$wgArticleRobotPolicies}}, but not robots.txt).
+
| The unexpanded wikitext is rendered (more or less, for details see [[Help:Template#msgnw|msgnw]]).
| 1.13+
 
 
|-
 
|-
| <nowiki>__STATICREDIRECT__</nowiki>
+
| <nowiki>{{raw:xyz}}</nowiki>
| On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title".
+
| '''[MW1.6+]''' Equivalent to <code><nowiki>{{msg:xyz}}</nowiki></code> above<ref>[http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=12925 Wikimedia SVN revision 12925]</ref>.
| {{mediawiki|rev:37928|1.13+}}
 
 
|-
 
|-
| <nowiki>#REDIRECT [[Page name]]</nowiki>
+
| <nowiki>{{subst:xyz}}</nowiki>
| Causes the current page to [[Help:Redirects|redirect]] viewers to another page.
+
| In the wikitext, the tag is substituted by the ''content'' (single-level evaluation only), see [[Help:Substitution]].
|}
+
|}{{-}}
  
==Variables and parser functions==
+
== Image modifiers ==
Variables return information about the current page, wiki, or date. Their syntax is similar to [[Help:Templates|templates]], but capitalized to help avoid conflicts. If a template has the same name and case as a variable, the variable will be used. Usage of the template can be forced by adding the "msg:" modifier (for example, "<code><nowiki>{{msg:CURRENTYEAR}}</nowiki></code>"). In some cases, adding parameters will force the parser to treat a variable as a template; for example, <code><nowiki>{{CURRENTDAYNAME|x}}</nowiki></code> tries to transclude "Template:CURRENTDAYNAME".
 
  
Parser functions are very similar to variables, but operate on user input instead of the current page. The first parameter is delimited by a colon (:) instead of a pipe (|). (This page does not document custom parser functions added by the {{mediawiki|Extension:ParserFunctions|ParserFunctions extension}}.)
+
:''For details see [[w:en:Wikipedia:Extended image syntax]].''
  
===Date & time===
+
These are [[Help:Image page|image]] modifiers used in <code><nowiki>[[File:title.ext|modifier|...|modifier]]</nowiki></code> links. Some are mutually exclusive, and then the last specified wins.  The last unrecognized modifier is used as '''caption''' for [[w:framed image|''framed'' images]] or together with ''[[w:thumbnail|thumbnail]]s''. It's also used as description <tt>alt=</tt>''text''.
The following variables return the current date and time according to the user's timezone [[Special:Preferences|preferences]], defaulting to the UTC timezone.
 
  
Due to MediaWiki and browser caching, these variables frequently show when the page was ''cached'' rather than the current time.
+
=== Size ===
  
{| {{prettytable}}
+
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
 +
! Word
 +
! Usage
 +
! Explanation
 
|-
 
|-
!{{Hl2}}| Variable
+
| framed <br/>frame <br/>enframed
!{{Hl2}}| Output
+
| <code><nowiki>[[File:Mediawiki.png|framed]]</nowiki></code>
!{{Hl2}}| Description
+
| Places an image in a ''frame'' with a description. Uses original size and stubbornly ignores width parameter if given. <br/>In general, far better to use thumb, as is only suitable for small images.
!{{Hl2}}| Versions
 
 
|-
 
|-
|{{Hl3}} colspan="4"| '''Year'''
+
| border
 +
| <code><nowiki>[[File:Mediawiki.png|border]]</nowiki></code>
 +
| Shows a 1 pixel border around the image.
 
|-
 
|-
| <nowiki>{{CURRENTYEAR}}</nowiki>
+
| thumbnail <br/>thumb
| {{CURRENTYEAR}}
+
| <code><nowiki>[[File:Mediawiki.png|thumbnail]]</nowiki></code>
| Year
+
| Modifies image size, sets it dependent on user's favorite thumbnail size in one's preferences, or on the given width parameter (see hereafter).
|
 
 
|-
 
|-
|{{Hl3}} colspan="4"| '''Month'''
+
| thumb=''xyz''
|-
+
| <code><nowiki>[[File:Mediawiki.png|thumb=Wiki.png]]</nowiki></code>
| <nowiki>{{CURRENTMONTH}}</nowiki>  
+
| Manual thumbnail: instead of displaying an automatically-sized thumbnail for <var>Mediawiki.png</var>, display the image <var>Wiki.png</var>.
| {{CURRENTMONTH}}
+
|-valign="top"
| Month (zero-padded number)
+
| ''width'' px <br/>100x200px
|
+
| <code><nowiki>[[File:Mediawiki.png|40px]]</nowiki></code> <br/><code><nowiki>[[File:Mediawiki.png|100x200px]]</nowiki></code>
|-
+
| Scales image to given ''width''&#160; in pixels. <br/>Scales image to no more than 100 pixels wide and no more than 200 high, but image scaled to retain its true aspect ratio within the boundary specified.
| <nowiki>{{CURRENTMONTHNAME}}</nowiki>
+
|}{{-}}
| {{CURRENTMONTHNAME}}
+
 
| Month (name)
+
=== Position ===
|
+
 
|-
+
:''For details see [[Help:Images and other uploaded files]].''
| <nowiki>{{CURRENTMONTHNAMEGEN}}</nowiki>
+
 
| {{CURRENTMONTHNAMEGEN}}
+
The positions are mutually exclusive; the last specified wins. [[Template:Clear]] can stop floating. For inline images only modifier ''px'' (see hereinbefore) is supported.
| Month ([http://en.wikipedia.org/wiki/genitive genitive form])
+
 
|
+
{| class="wikitable" width="100%"
|-
+
! Word
| <nowiki>{{CURRENTMONTHABBREV}}</nowiki>
+
! Usage
| {{CURRENTMONTHABBREV}}
+
! Explanation
| Month (abbreviation)
 
| 1.5+
 
|-
 
|{{Hl3}} colspan="4"| '''Day'''
 
|-
 
| <nowiki>{{CURRENTDAY}}</nowiki>
 
| {{CURRENTDAY}}
 
| Day of the month (unpadded number)
 
|
 
|-
 
| <nowiki>{{CURRENTDAY2}}</nowiki>
 
| {{CURRENTDAY2}}
 
| Day of the month (zero-padded number)
 
| 1.6+
 
|-
 
| <nowiki>{{CURRENTDOW}}</nowiki>
 
| {{CURRENTDOW}}
 
| Day of the week (unpadded number)
 
|
 
|-
 
| <nowiki>{{CURRENTDAYNAME}}</nowiki>
 
| {{CURRENTDAYNAME}}
 
| Day of the week (name)
 
|
 
|-
 
|{{Hl3}} colspan="4"| '''Time'''
 
 
|-
 
|-
| <nowiki>{{CURRENTTIME}}</nowiki>
+
| right
| {{CURRENTTIME}}
+
| <code><nowiki>[[File:Mediawiki.png|right]]</nowiki></code>
| Time (24-hour HH:mm format)
+
| Sets top of image to the right margin, text will flow from the left.
|
 
 
|-
 
|-
| <nowiki>{{CURRENTHOUR}}</nowiki>
+
| <nowiki>left</nowiki>
| {{CURRENTHOUR}}
+
| <code><nowiki>[[File:Mediawiki.png|left]]</nowiki></code>
| Hour (24-hour zero-padded number)
+
| Sets top of image to the left margin, content text will flow from the right.
|
 
 
|-
 
|-
|{{Hl3}} colspan="4"| '''Other'''
+
| <nowiki>none</nowiki>
 +
| <code><nowiki>[[File:Mediawiki.png|none]]</nowiki></code>
 +
| Image will be alone at left, content text will not appear with image.
 
|-
 
|-
| <nowiki>{{CURRENTWEEK}}</nowiki>
+
| center <br />centre
| {{CURRENTWEEK}}
+
| <code><nowiki>[[File:Mediawiki.png|center]]</nowiki></code>
| Week (number)
+
| Like ''none'' with image centered.  
|
+
|}{{-}}
|-
 
| <nowiki>{{CURRENTTIMESTAMP}}</nowiki>
 
| {{CURRENTTIMESTAMP}}
 
| [[wikipedia:ISO 8601|ISO 8601]] time stamp
 
| 1.7+
 
|}
 
  
The following variables do the same as the above, but using the site's local timezone instead of user preferences and UTC:
+
== Miscellany ==
* <nowiki>{{LOCALYEAR}}</nowiki>
 
* <nowiki>{{LOCALMONTH}}</nowiki>
 
* <nowiki>{{LOCALMONTHNAME}}</nowiki>
 
* <nowiki>{{LOCALMONTHNAMEGEN}}</nowiki>
 
* <nowiki>{{LOCALMONTHABBREV}}</nowiki>
 
* <nowiki>{{LOCALDAY}}</nowiki>
 
* <nowiki>{{LOCALDAY2}}</nowiki>
 
* <nowiki>{{LOCALDOW}}</nowiki>
 
* <nowiki>{{LOCALDAYNAME}}</nowiki>
 
* <nowiki>{{LOCALTIME}}</nowiki>
 
* <nowiki>{{LOCALHOUR}}</nowiki>
 
* <nowiki>{{LOCALWEEK}}</nowiki>
 
* <nowiki>{{LOCALTIMESTAMP}}</nowiki>
 
  
===Technical metadata===
+
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
Revision variables return data about the '''latest edit to the current page''', even if viewing an older version of the page.
+
! Word
{| {{prettytable}}
+
! Example
 +
! Explanation
 
|-
 
|-
!{{Hl2}}| Variable
+
| <nowiki>{{DISPLAYTITLE:</nowiki>''xyz''<nowiki>}}</nowiki>
!{{Hl2}}| Output
+
| ''no inline output''
!{{Hl2}}| Description
+
| '''[MW 1.7+]''' Modify the page's title [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=13572], enabled in Wikimedia projects since June 2007 ([http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=23393]). Also see {{h:mwg|AllowDisplayTitle}}.
!{{Hl2}}| Versions
 
 
|-
 
|-
|{{Hl3}} colspan="4"| '''Site'''
+
| <nowiki>{{DIRMARK}}</nowiki><br /><nowiki>{{DIRECTIONMARK}}</nowiki>
|-
+
| <code>{{DIRMARK}}</code><br /><code>{{DIRECTIONMARK}}</code>
| <nowiki>{{SITENAME}}</nowiki>
+
| '''[MW 1.7+]''' U+200E left-to-right or U+200D right-to-left mark.
| {{SITENAME}}
 
| The wiki's site name ({{mediawiki|Manual:$wgSitename|$wgSitename}}).
 
|
 
|-
 
| <nowiki>{{CURRENTVERSION}}</nowiki>
 
| {{CURRENTVERSION}}
 
| The wiki's MediaWiki version.
 
| 1.7+
 
 
|-
 
|-
 
| <nowiki>{{CONTENTLANGUAGE}}</nowiki>
 
| <nowiki>{{CONTENTLANGUAGE}}</nowiki>
| {{CONTENTLANGUAGE}}
+
| <code>{{CONTENTLANGUAGE}}</code>
| The wiki's default interface language ({{mediawiki|Manual:$wgLanguageCode|$wgLanguageCode}})
+
| '''[MW 1.7+]''' Code of the site's default interface language ({{h:mwg|LanguageCode}}).
| 1.7+
 
 
|-
 
|-
|{{Hl3}} colspan="4"| '''Latest revision to current page'''
+
| <nowiki>{{DEFAULTSORT:xyz}}</nowiki>
|-
+
| ''no inline output''
| <nowiki>{{REVISIONID}}</nowiki>
+
| '''[MW 1.10+]''' Sets a default [[Help:Categories#Sort_key|category sort key]] for the whole current page (also applying for category tags before this tag)<ref>"[[w:Wikipedia:Wikipedia Signpost/2007-01-02/Technology report|Technology report]]", English Wikipedia Signpost, January 2007</ref>.
| {{REVISIONID}}
 
| Unique ID
 
| 1.5+
 
|-
 
| <nowiki>{{REVISIONDAY}}</nowiki>
 
| {{REVISIONDAY}}
 
| Day edit was made (unpadded number)
 
| 1.8+
 
 
|-
 
|-
| <nowiki>{{REVISIONDAY2}}</nowiki>
+
| <nowiki>#REDIRECT</nowiki>  
| {{REVISIONDAY2}}
+
| <code>#REDIRECT&#160;[&#91;target&#93;]</code><br />at top of source page
| Day edit was made (zero-padded number)
+
| Creates a [[Help:Redirect|redirect]] to another page (to the target page).
| 1.8+
+
|}{{-}}
|-
 
| <nowiki>{{REVISIONMONTH}}</nowiki>
 
| {{REVISIONMONTH}}
 
| Month edit was made (unpadded number)
 
| 1.8+
 
|-
 
| <nowiki>{{REVISIONYEAR}}</nowiki>
 
| {{REVISIONYEAR}}
 
| Year edit was made
 
| 1.8+
 
|-
 
| <nowiki>{{REVISIONTIMESTAMP}}</nowiki>
 
| {{REVISIONTIMESTAMP}}
 
| Timestamp as of time of edit
 
| 1.8+
 
|}
 
  
===Statistics===
+
Despite its name <tt>MAGICNUMBER</tt> is no magic word, the [[m:Help:ISBN links|ISBN]] magic works only on the [[{{ns:4}}:{{int:Booksources}}|{{ns:8}}:Booksources]] page used by [[Special:Booksources]], but talking about <tt><nowiki>[[{{ns:4}}:{{int:Booksources}}|{{ns:8}}:Booksources]]</nowiki></tt> in a way working on any MediaWiki installation is esoteric enough to be noted here.
Numbers returned by these variables contain number separators, but can return raw numbers with the ":R" flag (for example, <code><nowiki>{{NUMBEROFPAGES}}</nowiki></code> = {{NUMBEROFPAGES}} and <code><nowiki>{{NUMBEROFPAGES:R}}</nowiki></code> = {{NUMBEROFPAGES:R}}). Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example <code><nowiki>{{PAGESINCATEGORY:Help}}</nowiki></code> and <code><nowiki>{{PAGESINCATEGORY:Help|R}}</nowiki></code>).
 
{| {{prettytable}}
 
|-
 
!{{Hl2}}| Variable
 
!{{Hl2}}| Output
 
!{{Hl2}}| Description
 
!{{Hl2}}| Versions
 
|-
 
|{{Hl3}} colspan="4"| '''Entire wiki'''
 
|-
 
| <nowiki>{{NUMBEROFPAGES}}</nowiki>
 
| {{NUMBEROFPAGES}}
 
| Number of wiki pages.
 
| 1.7+
 
|-
 
| <nowiki>{{NUMBEROFARTICLES}}</nowiki>
 
| {{NUMBEROFARTICLES}}
 
| Number of pages in main namespace.
 
|
 
|-
 
| <nowiki>{{NUMBEROFFILES}}</nowiki>
 
| {{NUMBEROFFILES}}
 
| Number of uploaded files.
 
| 1.5+
 
|-
 
| <nowiki>{{NUMBEROFEDITS}}</nowiki>
 
| {{NUMBEROFEDITS}}
 
| Number of page edits.
 
| {{mediawiki|rev:21319|1.10+}}
 
|-
 
| <nowiki>{{NUMBEROFUSERS}}</nowiki>
 
| {{NUMBEROFUSERS}}
 
| Number of registered users.
 
| 1.7+
 
|-
 
| <nowiki>{{NUMBEROFADMINS}}</nowiki>
 
| {{NUMBEROFADMINS}}
 
| Number of users in the ''sysop'' {{mediawiki|Manual:User rights|group}}.
 
| 1.7+
 
|-
 
| <nowiki>{{NUMBERINGROUP:groupname}}</nowiki>
 
| {{NUMBERINGROUP:bureaucrat}} <br /><nowiki>({{NUMBERINGROUP:bureaucrat}} used here)</nowiki>
 
| Number of users in a specific {{mediawiki|Manual:User rights|group}}.
 
| {{mediawiki|rev:40116|1.14+}}
 
|-
 
|{{Hl3}} colspan="4"| '''Per namespace'''
 
|-
 
| <nowiki>{{PAGESINNS:2}}</nowiki><br /><nowiki>{{PAGESINNAMESPACE:2}}</nowiki>
 
| ''not enabled''
 
| Number of pages in the given [[Help:Namespaces|namespace]] (replace 2 with the relevant [[Manual:Namespace|namespace ID]]). E.g. <nowiki>{{PAGESINNAMESPACE:14}}</nowiki> equals the number of categories. <!-- {{NUMBEROFCATEGORIES}} --> Disabled by default, enable with {{mediawiki|Manual:$wgAllowSlowParserFunctions|$wgAllowSlowParserFunctions}}.
 
| 1.7+
 
|-
 
|{{Hl3}} colspan="4"| '''Other'''
 
|-
 
| <nowiki>{{PAGESINCATEGORY:Help}}</nowiki><br /><nowiki>{{PAGESINCAT:Help}}</nowiki>
 
| {{PAGESINCATEGORY:Help}}<br />{{PAGESINCAT:Help}}
 
| Number of pages in the given [[Help:Categories|category]] (replace "Help" with the relevant category name).
 
| {{mediawiki|rev:32932|1.13+}}
 
|-
 
| <nowiki>{{PAGESIZE:Help:Magic_words}}</nowiki>
 
| {{PAGESIZE:Help:Magic_words}}
 
| Returns the byte size of the specified page.
 
| {{mediawiki|rev:33551|1.13+}}
 
|}
 
  
===URL data===
+
===Language-dependent word conversions===
====URLs====
+
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
{| {{prettytable}}
+
! Word
 +
! Example
 +
! Explanation
 
|-
 
|-
!{{Hl2}}| Variable
+
| <nowiki>{{CURRENTMONTHNAMEGEN}}</nowiki>
!{{Hl2}}| Output
+
| <code>{{CURRENTMONTHNAMEGEN}}</code>
!{{Hl2}}| Description
+
| [[w:genitive case|Genitive form]] of month name used for Czech, Polish, Ukrainian[http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/]
!{{Hl2}}| Versions
 
|-
 
| <nowiki>{{SERVER}}</nowiki>
 
| {{SERVER}}
 
| domain URL ({{mediawiki|Manual:$wgServer|$wgServer}})
 
|
 
|-
 
| <nowiki>{{SERVERNAME}}</nowiki>
 
| {{SERVERNAME}}
 
| domain name ({{mediawiki|Manual:$wgServerName|$wgServerName}})
 
|
 
|-
 
| <nowiki>{{SCRIPTPATH}}</nowiki>
 
| {{SCRIPTPATH}}
 
| relative script path ({{mediawiki|Manual:$wgScriptPath|$wgScriptPath}})
 
|
 
 
|-
 
|-
| <nowiki>{{localurl:</nowiki>''page name''<nowiki>}}</nowiki><br /><nowiki>{{localurl:page name|</nowiki>''query string''<nowiki>}}</nowiki>
+
| <nowiki>{{LOCALMONTHNAMEGEN}}</nowiki>
| {{localurl:page name}}<br />{{localurl:page name|query string}}
+
| <code>{{LOCALMONTHNAMEGEN}}</code>
| relative path to title
+
| [[w:genitive case|Genitive form]] of month name used for Czech, Polish, Ukrainian (local time)
|
 
 
|-
 
|-
| <nowiki>{{fullurl:</nowiki>''page name''<nowiki>}}</nowiki><br /><nowiki>{{fullurl:page name|</nowiki>''query_string''<nowiki>}}</nowiki>
+
| {&#123;grammar:''case &#124; word'' &#125;}
| {{fullurl:page name}}<br />{{fullurl:page name|query_string}}
+
| <nowiki>{{grammar:7sg|Wikipedie}}</nowiki><br />on [[:cs:]] is <code>Wikipedií</code>.
| absolute path to title
+
| Derived word forms in inflected languages like [[:cs:|Czech]] [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/classes/LanguageCs.php]
| 1.5+
 
 
|-
 
|-
| <nowiki>{{filepath:Wiki.png}}</nowiki>
+
| {&#123;plural:''count &#124;form1 &#124;form2'' &#125;}<br />{&#123;plural:''count&#160;&#124;1st&#160;&#124;&#160;2nd&#160;&#124;&#160;3rd&#160;''&#125;}  
| {{filepath:Wiki.png}}
+
| <nowiki>{{plural: 2 | is | are }}</nowiki><br />outputs <code>{{plural: 2 | is |are }}</code><br /><nowiki>{{plural: 1 | this | these }}</nowiki><br />outputs <code>{{plural: 1 |this | these }}</code><br /><nowiki>{{plural: 0 | his | their }}</nowiki><br />outputs <code>{{plural: 0 |his | their }}</code>
| The absolute URL to a media file.
+
| ''count'' '''1''' yields ''form1'' (singular), [[w:Plural|plural]] transformations are used for languages like [[:ru:|Russian]] [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/classes/LanguageRu.php] based on "count mod 10".
| {{mediawiki|rev:25854|1.12+}}
+
|}{{-}}
|-
 
| <nowiki>{{urlencode:x y z}}</nowiki>
 
| <code>{{urlencode:x y z}}</code>
 
| The input encoded for use in URLs.
 
| {{mediawiki|rev:14273|1.7+}}
 
|-
 
| <nowiki>{{anchorencode:x y z}}</nowiki>
 
| <code>{{anchorencode:x y z}}</code>
 
| The input encoded for use in URL section anchors (after the '#' symbol in a URL).
 
| {{mediawiki|rev:16279|1.8+}}
 
|}
 
  
====Page names====
+
"Grammar" and "Plural" are language-dependent functions, defined in [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/classes/LanguageCs.php], [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/classes/LanguageRu.php], etc. (note that in PHP, the modulo operator is the percent sign).
{| {{prettytable}}
 
|-
 
!{{Hl2}}| Variable
 
!{{Hl2}}| Output
 
!{{Hl2}}| Description
 
!{{Hl2}}| Versions
 
|-
 
| <nowiki>{{FULLPAGENAME}}</nowiki>
 
| {{FULLPAGENAME}}
 
| Namespace and page title.
 
| 1.6+
 
|-
 
| <nowiki>{{PAGENAME}}</nowiki>
 
| {{PAGENAME}}
 
| Page title.
 
|
 
|-
 
| <nowiki>{{BASEPAGENAME}}</nowiki>
 
| {{BASEPAGENAME}}
 
| Page title excluding the current [[Help:Subpages|subpage]] and namespace ("Title" on "Title/foo").
 
| 1.7+
 
|-
 
| <nowiki>{{SUBPAGENAME}}</nowiki>
 
| {{SUBPAGENAME}}
 
| The [[Help:Subpages|subpage]] title ("foo" on "Title/foo").
 
| 1.6+
 
|-
 
| <nowiki>{{SUBJECTPAGENAME}}</nowiki>
 
| {{SUBJECTPAGENAME}}
 
| The namespace and title of the associated content page.
 
| 1.7+
 
|-
 
| <nowiki>{{TALKPAGENAME}}</nowiki>
 
| {{TALKPAGENAME}}
 
| The namespace and title of the associated talk page.
 
| 1.7+
 
|}
 
  
The following are URL-encoded equivalents:
+
"Grammar" can either be applied to predefined words only, or to arbitrary words, depending on whether the definition is just a 2D array, or involves string manipulations. See also [[:cs:Šablona:Wikivar/GRAMMAR]].
* <nowiki>{{FULLPAGENAMEE}}</nowiki>
 
* <nowiki>{{PAGENAMEE}}</nowiki>
 
* <nowiki>{{BASEPAGENAMEE}}</nowiki>
 
* <nowiki>{{SUBPAGENAMEE}}</nowiki>
 
* <nowiki>{{SUBJECTPAGENAMEE}}</nowiki>
 
* <nowiki>{{TALKPAGENAMEE}}</nowiki>
 
  
====Namespaces====
+
"Plural" is a site-language-dependent switch function, controlled by function convertPlural in Language.php (which distinguishes between 1 and "not 1"), for some languages overridden in Languagexx.php, e.g. for French (which distinguishes between <=1 and >1) and Russian, which uses a grammar case for amounts ending in 1 (1, 21, 31,...), another case for amounts ending in 2 to 4 (2, 3, 4, 22, 23, 24, ...) and still another case for the remaining quantities.
{| {{prettytable}}
 
|-
 
!{{Hl2}}| Variable
 
!{{Hl2}}| Output
 
!{{Hl2}}| Description
 
!{{Hl2}}| Versions
 
|-
 
| <nowiki>{{NAMESPACE}}</nowiki>
 
| {{NAMESPACE}}
 
| Namespace (name)
 
|-
 
| <nowiki>{{SUBJECTSPACE}}</nowiki><br /><nowiki>{{ARTICLESPACE}}</nowiki>
 
| {{SUBJECTSPACE}}<br />{{ARTICLESPACE}}
 
| Name of the associated content namespace
 
| 1.7+
 
|-
 
| <nowiki>{{TALKSPACE}}</nowiki>
 
| {{TALKSPACE}}
 
| Name of the associated talk namespace
 
| 1.7+
 
|}
 
  
The following are URL-encoded equivalents:
+
As opposed to [[ParserFunctions]], "plural" accepts points and commas in numbers and interprets them in a site-language-specific way (depending on $separatorTransformTable in Messagesxx.php); on this site:
* <nowiki>{{NAMESPACEE}}</nowiki>
+
*<nowiki>{{plural:1.000|a|b|c}}</nowiki> gives {{plural:1.000|a|b|c}}
* <nowiki>{{SUBJECTSPACEE}}</nowiki>
+
*<nowiki>{{plural:1,000|a|b|c}}</nowiki> gives {{plural:1,000|a|b|c}}
* <nowiki>{{TALKSPACEE}}</nowiki>
 
  
<code><nowiki>{{ns:}}</nowiki></code> returns the localized namespace name for that number constant. The default values are:
+
(on e.g. the German and the Dutch sites reversed w.r.t. the result on English sites).
{| {{prettytable}}
 
|-
 
!{{Hl2}}| Usage
 
!{{Hl2}}| Output
 
|-
 
| <nowiki>{{ns:-2}} or {{ns:Media}}</nowiki>
 
| {{ns:-2}}
 
|-
 
| <nowiki>{{ns:-1}} or {{ns:Special}}</nowiki>
 
| {{ns:-1}}
 
|-
 
| <nowiki>{{ns:0}}</nowiki>
 
| {{ns:0}}
 
|-
 
| <nowiki>{{ns:1}} or {{ns:Talk}}</nowiki>
 
| {{ns:1}}
 
|-
 
| <nowiki>{{ns:2}} or {{ns:User}}</nowiki>
 
| {{ns:2}}
 
|-
 
| <nowiki>{{ns:3}} or {{ns:User_talk}}</nowiki>
 
| {{ns:3}}
 
|-
 
| <nowiki>{{ns:4}} or {{ns:Project}}</nowiki>
 
| {{ns:4}}
 
|-
 
| <nowiki>{{ns:5}} or {{ns:Project_talk}}</nowiki>
 
| {{ns:5}}
 
|-
 
| <nowiki>{{ns:6}} or {{ns:Image}}</nowiki>
 
| {{ns:6}}
 
|-
 
| <nowiki>{{ns:7}} or {{ns:Image_talk}}</nowiki>
 
| {{ns:7}}
 
|-
 
| <nowiki>{{ns:8}} or {{ns:MediaWiki}}</nowiki>
 
| {{ns:8}}
 
|-
 
| <nowiki>{{ns:9}} or {{ns:MediaWiki_talk}}</nowiki>
 
| {{ns:9}}
 
|-
 
| <nowiki>{{ns:10}} or {{ns:Template}}</nowiki>
 
| {{ns:10}}
 
|-
 
| <nowiki>{{ns:11}} or {{ns:Template_talk}}</nowiki>
 
| {{ns:11}}
 
|-
 
| <nowiki>{{ns:12}} or {{ns:Help}}</nowiki>
 
| {{ns:12}}
 
|-
 
| <nowiki>{{ns:13}} or {{ns:Help_talk}}</nowiki>
 
| {{ns:13}}
 
|-
 
| <nowiki>{{ns:14}} or {{ns:Category}}</nowiki>
 
| {{ns:14}}
 
|-
 
| <nowiki>{{ns:15}} or {{ns:Category_talk}}</nowiki>
 
| {{ns:15}}
 
|}
 
  
===Formatting===
+
"Plural" is used in various system messages, e.g. {{msg|nmembers}}, where it uses interface language instead of site language.
{| {{prettytable}}
 
!{{Hl2}}| Usage
 
!{{Hl2}}| Output
 
!{{Hl2}}| Description
 
!{{Hl2}}| Version
 
|-
 
|-
 
| <nowiki>{{lc:XYZ}}</nowiki>
 
| {{lc:XYZ}}
 
| The lowercase input.
 
| 1.5+
 
|-
 
| <nowiki>{{lcfirst:XYZ}}</nowiki>
 
| {{lcfirst:XYZ}}
 
| The input with the first character lowercase.
 
| 1.5+
 
|-
 
| <nowiki>{{uc:xyz}}</nowiki>
 
| {{uc:xyz}}
 
| The uppercase input.
 
| 1.5+
 
|-
 
| <nowiki>{{ucfirst:xyz}}</nowiki>
 
| {{ucfirst:xyz}}
 
| The input with the first character uppercase.
 
| 1.5+
 
|-
 
| <nowiki>{{formatnum:-987654321.654321}}</nowiki>
 
| {{formatnum:-987654321.654321}}
 
| The input with decimal and decimal group separators, and localized digit script, according to the wiki's default locale.
 
| 1.7+
 
|-
 
| <nowiki>{{padleft:xyz|5|_}}</nowiki><br /><nowiki>{{padleft:xyz|5}}</nowiki>
 
| {{padleft:xyz|5|_}}<br />{{padleft:xyz|5}}
 
| The input (first parameter) padded on the left side to the specified width (second parameter) using the specified character (third parameter). If a padding character isn't specified, '0' is used by default.<br />'''bug:''' multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters.
 
| 1.8+
 
|-
 
| <nowiki>{{padright:xyz|5|_}}</nowiki><br /><nowiki>{{padright:xyz|5}}</nowiki>
 
| {{padright:xyz|5|_}}<br />{{padright:xyz|5}}
 
| Identical to padleft, but adds padding characters to the right side.
 
|-
 
| <nowiki>{{DIRMARK}}</nowiki><br /><nowiki>{{DIRECTIONMARK}}</nowiki>
 
| {{DIRMARK}}<br />{{DIRECTIONMARK}}
 
| Outputs a unicode-directional mark that matches the wiki's default language's direction (<code>&amp;lrm;</code> on left-to-right wikis, <code>&amp;rlm;</code> on right-to-left wikis), useful in text with multi-directional text.
 
| 1.7+
 
|-
 
| <nowiki>{{plural:2|is|are}}</nowiki>
 
| {{plural:2|is|are}}
 
| Outputs the correct given pluralization form (parameters except first) depending on the count (first parameter). Plural transformations are used for languages like Russian based on "count mod 10".
 
|}
 
  
===Miscellaneous===
+
== See also ==
{| {{prettytable}}
+
* [[mw:Help:Extension:ParserFunctions|ParserFunctions]] '''#expr:''', '''#if:''', '''#ifeq:''', etc.
!{{Hl2}}| Usage
+
* [[mw:Manual:Magic words]]
!{{Hl2}}| Output
+
* [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/Language.php Source for Language.php]
!{{Hl2}}| Description
+
* [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/includes/MagicWord.php Source for MagicWord.php]
!{{Hl2}}| Version
+
* [[m:Extending_wiki_markup#Parser_functions|Adding parser functions]]
|-
+
* [[mw:Extension:Variables]]'' : MediaWiki extension to add new magic words''
| <nowiki>{{#language:eo}}</nowiki>
 
| {{#language:eo}}
 
| The native name for the given language code.
 
| 1.7+
 
|-
 
| <nowiki>{{#special:userlogin}}</nowiki>
 
| {{#special:userlogin}}
 
| The localized name for the given canonical Special: page.
 
| {{mediawiki|rev:17321|1.9+}}
 
|-
 
| <nowiki>{{#tag:tagname}}</nowiki><br /><nowiki>{{#tag:tagname|inner content|parameter=value|parameter2=value}}</nowiki>
 
| ''(depends on parser tag)''
 
| Alias for XML-style parser or extension tags, but parsing wiki code. Attribute values can be passed as parameter values ('<code><nowiki><tagname attribute="value"></nowiki></code>' &rarr; '<code><nowiki>{{#tag:tagname|attribute=value}}</nowiki></code>'), and inner content as an unnamed parameter ('<code><nowiki><tagname>content</tagname></nowiki></code>' &rarr; '<code><nowiki>{{#tag:tagname|content}}</nowiki></code>').
 
| [[rev:29482|1.12+]]
 
|}
 
  
{{languages}}
+
==Notes and references==
 +
<div style="font-size:0.9em;"><references/></div>
 +
{{H:f|enname=Magic words}}
  
[[Category:Help|{{PAGENAME}}]]
+
[[Category:Editor handbook]]
[[Category:Time|{{PAGENAME}}]]
 
[[Category:Magic words|{{PAGENAME}}]]
 

Latest revision as of 22:02, 10 October 2013

Comment See Help:Magic words on www.mediawiki.org for more magic words in the MediaWiki software. The page here is currently kept for things not yet merged to www.mediawiki.org and for documentation specific to the Wikimedia Foundation. If something is missing from both pages, check the full version of this page and restore the lacking information.


MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins +/-

This is an organized index of magic words used in MediaWiki.

A "magic word" is a symbol recognized by the MediaWiki software and which when seen in the non-commented text of the page, triggers the software to do something other than display that symbol, or transclude a page with that name, but instead to use the symbol directly.

A magic word can be:

  • a behavior switch, called using an upper case word, preceded and followed by pairs of underscores, e.g. __NOTOC__
  • XML-style tags, preceded by "<" (and for the end tag "/") and followed by ">", as in <nowiki>...</nowiki>
  • a parser function: similar to a template, a word preceded by the symbols "{{" and followed by "}}", and optionally parameter definitions between pipe characters, except that the part before the first pipe (or without pipes, the text between the braces) contains a colon (":"), e.g. {{ns:3}} and {{#ifexpr:{{{1}}}>3|large|small}}
  • a variable: similar to a template without parameters, a word preceded by the symbols "{{" and followed by "}}", except the word used is in all upper case, e.g. {{CURRENTDAY}}
  • a template modifier
  • an image modifier

If a page in the template namespace has the same name as a magic word, the magic word will be invoked instead. If you discover you absolutely have to define a template with the same name as a magic word, prefix the name of the template with "msg:" or the name of the template namespace ("Template:"). See below for further details if you need this feature.

Variables

For details see Help:Variable

Page names and related info

Word Example Explanation
This page "User:Anonymous user/sandbox/my page" page
"User talk:Anonymous user/sandbox/my page" page
{{PAGENAME}} Magic words Anonymous user/sandbox/my page Returns the name of the current page, including all levels (Title/Subtitle). This does not include the name of the namespace.
{{PAGENAMEE}} Magic_words Anonymous_user/sandbox/my_page More URL-friendly percent encoded special characters (to use an article name in an external link).
{{BASEPAGENAME}}
{{BASEPAGENAMEE}}
Magic words
Magic_words
Anonymous user/sandbox
Anonymous_user/sandbox
[MW 1.7+] The basename of a subpage ("Title/Other" on "Title/Other/Subtitle"), see Help:Link.
{{SUBPAGENAME}}
{{SUBPAGENAMEE}}
Magic words
Magic_words
my page
my_page
[MW 1.6+] Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages, see Help:Link.
{{NAMESPACE}}
{{NAMESPACEE}}
Help
Help
User
User
Returns the name of the namespace the current page resides in. Note that this returns an empty string for the main (article) space.
User talk
User_talk
{{FULLPAGENAME}}
{{FULLPAGENAMEE}}
Help:Magic words
Help:Magic_words
User:Anonymous user/sandbox/my page
User:Anonymous_user/sandbox/my_page
[MW 1.6+] Shorthands for NAMESPACE+PAGENAME.
User talk:Anonymous user/sandbox/my page
User_talk:Anonymous_user/sandbox/my_page
{{TALKSPACE}}
{{TALKSPACEE}}
Help talk
Help_talk
User talk
User_talk
[MW 1.7+] Name of next odd namespace (e.g. 4 ⇒ 5).
{{SUBJECTSPACE}}
{{SUBJECTSPACEE}}
Help
Help
User
User
[MW 1.7+] Name of last even namespace (e.g. 5 ⇒ 4).
{{ARTICLESPACE}}
{{ARTICLESPACEE}}
Help
Help
User
User
[MW 1.7+] An alias for SUBJECTSPACE(E).
{{TALKPAGENAME}}
{{TALKPAGENAMEE}}
Help talk:Magic words
Help_talk:Magic_words
User talk:Anonymous user/sandbox/my page
User_talk:Anonymous_user/sandbox/my_page
[MW 1.7+] FULLPAGENAME in its TALKSPACE.
{{SUBJECTPAGENAME}}
{{SUBJECTPAGENAMEE}}
Help:Magic words
Help:Magic_words
User:Anonymous user/sandbox/my page
User:Anonymous_user/sandbox/my_page
[MW 1.7+] FULLPAGENAME in its SUBJECTSPACE.
{{ARTICLEPAGENAME}}
{{ARTICLEPAGENAMEE}}
Help:Magic words
Help:Magic_words
User:Anonymous user/sandbox/my page
User:Anonymous_user/sandbox/my_page
[MW 1.7+] An alias for SUBJECTPAGENAME(E).
{{REVISIONID}} 71975 N/A [MW 1.5+] The unique identifying number of a page, see Help:Diff. Note that when editing a page, this value is null.
{{REVISIONDAY}} 10 N/A [MW 1.8+] The day on which the page was last modified.
{{REVISIONDAY2}} 10 N/A [MW 1.8+] The day on which the page was last modified, but with a leading zero (01 … 31).
{{REVISIONMONTH}} 10 N/A [MW 1.8+] The month in which the page was last modified.
{{REVISIONYEAR}} 2013 N/A [MW 1.8+] The year in which the page was last modified.
{{REVISIONTIMESTAMP}} 20131010220200 N/A [MW 1.8+] ISO 8601 time stamp, indicating when the page was last modified.
{{SITENAME}} SacredWiki Value of $wgSitename.
{{SERVER}} https://www.sacredwiki.org Value of $wgServer.
{{SCRIPTPATH}} [MW 1.5+] $wgScriptPath.
{{SERVERNAME}} www.sacredwiki.org [MW 1.5+] $wgServerName.


Template modifiers

Usage Explanation
{{:xyz}} A bare colon is not a template modifier, it's the prefix for the main namespace. Test e.g. article {{:UTC}} vs. template {{UTC}}.
Using this syntax you include the text of the main namespace article xyz in another article.
{{int:xyz}} Same as {{MediaWiki:xyz}}, except standard message translation is applied depending on subpages and content/user/uselang language. Another difference is: this doesn't appear under "Templates used on this page:". Rendered as ⧼xyz⧽ if MediaWiki:xyz doesn't exist. See also Help:System message.
{{msg:xyz}} Even if there is a magic word named "xyz", use template:xyz unless the template doesn't exist (equivalent to {{template:xyz}}). Normally, magic words have priority when there is a conflict.
{{msgnw:xyz}} The unexpanded wikitext is rendered (more or less, for details see msgnw).
{{raw:xyz}} [MW1.6+] Equivalent to {{msg:xyz}} above<ref>Wikimedia SVN revision 12925</ref>.
{{subst:xyz}} In the wikitext, the tag is substituted by the content (single-level evaluation only), see Help:Substitution.


Image modifiers

For details see w:en:Wikipedia:Extended image syntax.

These are image modifiers used in [[File:title.ext|modifier|...|modifier]] links. Some are mutually exclusive, and then the last specified wins. The last unrecognized modifier is used as caption for framed images or together with thumbnails. It's also used as description alt=text.

Size

Word Usage Explanation
framed
frame
enframed
[[File:Mediawiki.png|framed]] Places an image in a frame with a description. Uses original size and stubbornly ignores width parameter if given.
In general, far better to use thumb, as is only suitable for small images.
border [[File:Mediawiki.png|border]] Shows a 1 pixel border around the image.
thumbnail
thumb
[[File:Mediawiki.png|thumbnail]] Modifies image size, sets it dependent on user's favorite thumbnail size in one's preferences, or on the given width parameter (see hereafter).
thumb=xyz [[File:Mediawiki.png|thumb=Wiki.png]] Manual thumbnail: instead of displaying an automatically-sized thumbnail for Mediawiki.png, display the image Wiki.png.
width px
100x200px
[[File:Mediawiki.png|40px]]
[[File:Mediawiki.png|100x200px]]
Scales image to given width  in pixels.
Scales image to no more than 100 pixels wide and no more than 200 high, but image scaled to retain its true aspect ratio within the boundary specified.


Position

For details see Help:Images and other uploaded files.

The positions are mutually exclusive; the last specified wins. Template:Clear can stop floating. For inline images only modifier px (see hereinbefore) is supported.

Word Usage Explanation
right [[File:Mediawiki.png|right]] Sets top of image to the right margin, text will flow from the left.
left [[File:Mediawiki.png|left]] Sets top of image to the left margin, content text will flow from the right.
none [[File:Mediawiki.png|none]] Image will be alone at left, content text will not appear with image.
center
centre
[[File:Mediawiki.png|center]] Like none with image centered.


Miscellany

Word Example Explanation
{{DISPLAYTITLE:xyz}} no inline output [MW 1.7+] Modify the page's title [1], enabled in Wikimedia projects since June 2007 ([2]). Also see $wgAllowDisplayTitle.
{{DIRMARK}}
{{DIRECTIONMARK}}

[MW 1.7+] U+200E left-to-right or U+200D right-to-left mark.
{{CONTENTLANGUAGE}} en [MW 1.7+] Code of the site's default interface language ($wgLanguageCode).
{{DEFAULTSORT:xyz}} no inline output [MW 1.10+] Sets a default category sort key for the whole current page (also applying for category tags before this tag)<ref>"Technology report", English Wikipedia Signpost, January 2007</ref>.
#REDIRECT #REDIRECT [[target]]
at top of source page
Creates a redirect to another page (to the target page).


Despite its name MAGICNUMBER is no magic word, the ISBN magic works only on the MediaWiki:Booksources page used by Special:Booksources, but talking about [[{{ns:4}}:{{int:Booksources}}|{{ns:8}}:Booksources]] in a way working on any MediaWiki installation is esoteric enough to be noted here.

Language-dependent word conversions

Word Example Explanation
{{CURRENTMONTHNAMEGEN}} November Genitive form of month name used for Czech, Polish, Ukrainian[3]
{{LOCALMONTHNAMEGEN}} November Genitive form of month name used for Czech, Polish, Ukrainian (local time)
{{grammar:case | word }} {{grammar:7sg|Wikipedie}}
on cs: is Wikipedií.
Derived word forms in inflected languages like Czech [4]
{{plural:count |form1 |form2 }}
{{plural:count |1st | 2nd | 3rd }}
{{plural: 2 | is | are }}
outputs are
{{plural: 1 | this | these }}
outputs this
{{plural: 0 | his | their }}
outputs their
count 1 yields form1 (singular), plural transformations are used for languages like Russian [5] based on "count mod 10".


"Grammar" and "Plural" are language-dependent functions, defined in [6], [7], etc. (note that in PHP, the modulo operator is the percent sign).

"Grammar" can either be applied to predefined words only, or to arbitrary words, depending on whether the definition is just a 2D array, or involves string manipulations. See also cs:Šablona:Wikivar/GRAMMAR.

"Plural" is a site-language-dependent switch function, controlled by function convertPlural in Language.php (which distinguishes between 1 and "not 1"), for some languages overridden in Languagexx.php, e.g. for French (which distinguishes between <=1 and >1) and Russian, which uses a grammar case for amounts ending in 1 (1, 21, 31,...), another case for amounts ending in 2 to 4 (2, 3, 4, 22, 23, 24, ...) and still another case for the remaining quantities.

As opposed to ParserFunctions, "plural" accepts points and commas in numbers and interprets them in a site-language-specific way (depending on $separatorTransformTable in Messagesxx.php); on this site:

  • {{plural:1.000|a|b|c}} gives a
  • {{plural:1,000|a|b|c}} gives b

(on e.g. the German and the Dutch sites reversed w.r.t. the result on English sites).

"Plural" is used in various system messages, e.g. message with id 'nmembers' (talk), where it uses interface language instead of site language.

See also

Notes and references

<references/>


+/-

Links to other help pages

Help contents
Meta · Wikinews · Wikipedia · Wikiquote · Wiktionary · Commons: · mw: · b: · s: · mw:Manual · Google
Versions of this help page (for other languages see further)
Meta · Wikinews · Wikipediahttp://en.wikipedia.org/index.php/Help:Magic_words · Wikiquote · Wiktionary
What links here on Meta or from Meta · Wikipedia · MediaWiki
Reading
Go · Search · Stop words · Namespace · Page name · Section · Backlinks · Redirect · Category · Image page · Special pages · Printable version
Tracking changes
Recent changes (enhanced) | Related changes · Watching pages · Diff · Page history · Edit summary · User contributions · Minor edit · Patrolled edit
Logging in and preferences
Logging in · Preferences · User style
Editing
Starting a new page · Advanced editing · Editing FAQ · Edit toolbar · Export · Import · Shortcuts · Edit conflict · Page size
Referencing
Links · URLs · Piped links · Interwiki linking · Footnotes
Style and formatting
Wikitext examples · CSS · Reference card · HTML in wikitext · Formula · List · Table · Sorting · Colors · Images and file uploads
Fixing mistakes
Show preview · Testing · Reverting edits
Advanced functioning
Expansion · Template · Advanced templates · Parser function · Parameter default · Variable · System message · Substitution · Array · Calculation · Embed page
Others
Special characters · Renaming (moving) a page · Talk page · Signatures · Sandbox · Legal issues for editors