Help:Magic words

From GM Wiki

Jump to: navigation, search
MediaWiki Handbook: Contents, Readers, Editors, Moderators, System admins +/-

This is an organised index of Magic words used in MediaWiki. Tags such as "[MW1.5+]" indicate the version that first supported the magic word. "XYZ" indicates user input, which is used in the example.

Contents

Table of contents

For details see Help:Section
Word Explanation
__NOTOC__ Hides ToC on the current page.
__FORCETOC__ Forces the table of contents to appear.
__TOC__ Places a ToC here (overriding any __NOTOC__).

More magic

Word Explanation
__NOEDITSECTION__ Hides the edit links beside headings.
__NEWSECTIONLINK__ [MW1.7+] Gives a "+"-link next to the edit-tab to make a new section on a non-talk page.
__NOCONTENTCONVERT__
__NOCC__
Don't perform the content language conversion (character and phase) in article display; for example, Chinese zh with zh_cn, zh_tw, zh_sg, zh_hk.
__NOGALLERY__ [MW1.7+] This magic word allows images in category pages to be displayed as inline links instead of gallery.
__NOTITLECONVERT__
__NOTC__
Like __NOCC__ but affecting article title only.
__END__ Allows for trailing whitespace to be included in the page save.
__START__ This magic word has no effect but an ID in MagicWord.php (MAG_START).

Variables

For details see Help:Variable

Time

The time in UTC.

Word Example Explanation
{{CURRENTDAY}} 6 Displays the current day in numeric form.
{{CURRENTDAY2}} 06 [MW1.6+] Same as {{CURRENTDAY}}, but with leading zero (01 .. 31).
{{CURRENTDAYNAME}} Monday Name of the day in the language of the project or English.
{{CURRENTDOW}} 1 Same as {{CURRENTDAYNAME}}, but as a number (0=Sunday, 1=Monday...).
{{CURRENTMONTH}} 02 The number 01 .. 12 of the month.
{{CURRENTMONTHABBREV}} Feb [MW1.5+] Same as {{CURRENTMONTH}}, but in abbreviated form as Jan .. Dec.
{{CURRENTMONTHNAME}} February Same as {{CURRENTMONTH}}, but in named form January .. December.
{{CURRENTTIME}} 21:00 The current time (00:00 .. 23:59).
{{CURRENTHOUR}} Template:CURRENTHOUR The current hour (00 .. 23).
{{CURRENTWEEK}} 6 Number of the current week (1-53) according to ISO 8601 with no leading zero.
{{CURRENTYEAR}} 2012 Returns the current year.
{{CURRENTTIMESTAMP}} 20120206210047 [MW1.7+] ISO 8601 time stamp.

Local time

The time depending on the local timezone of the wiki. (All words [MW1.8+] )

Word Example Explanation
{{LOCALDAY}} Template:LOCALDAY Displays the local day of the month in numeric form.
{{LOCALDAY2}} Template:LOCALDAY2 Same as {{LOCALDAY}}, but with a leading zero (01 .. 31).
{{LOCALDAYNAME}} Template:LOCALDAYNAME Name of the day in the language of the project or English.
{{LOCALDOW}} Template:LOCALDOW Same as {{LOCALDAYNAME}}, but as a number (0=Sunday, 1=Monday...).
{{LOCALMONTH}} Template:LOCALMONTH The number 01 .. 12 of the month.
{{LOCALMONTHABBREV}} Template:LOCALMONTHABBREV Same as {{LOCALMONTH}}, but in abbreviated form as Jan .. Dec.
{{LOCALMONTHNAME}} Template:LOCALMONTHNAME Same as {{LOCALMONTH}}, but in named form as January .. December.
{{LOCALTIME}} Template:LOCALTIME The local time (00:00 .. 23:59).
{{LOCALHOUR}} Template:LOCALHOUR The local hour (00 .. 23).
{{LOCALWEEK}} Template:LOCALWEEK Number of the local week (1-53) according to ISO 8601 with no leading zero.
{{LOCALYEAR}} Template:LOCALYEAR Returns the local year.
{{LOCALTIMESTAMP}} Template:LOCALTIMESTAMP ISO 8601 time stamp.

Statistics

Word Example Explanation
{{CURRENTVERSION}} 1.7.1 [MW1.7+] $wgVersion [1]
{{NUMBEROFARTICLES}}
{{NUMBEROFARTICLES:R}}
118
118
A variable which returns the total number of articles on the Wiki.
{{NUMBEROFPAGES}}
{{NUMBEROFPAGES:R}}
1,875
1875
[MW1.7+] Returns the total number of pages. [2]
{{NUMBEROFFILES}}
{{NUMBEROFFILES:R}}
240
240
[MW1.5+] Returns the number of uploaded files (rows in the image table).
{{NUMBEROFUSERS}}
{{NUMBEROFUSERS:R}}
7
7
[MW1.7+] Returns the number of registered users (rows in the user table).
{{NUMBEROFADMINS}}
{{NUMBEROFADMINS:R}}
3
3
[MW1.7+] Returns the number of administrators (sysop, bureaucrat, steward and checkuser).
{{PAGESINNAMESPACE}}  disabled here Longer alias of PAGESINNS
{{PAGESINNS:ns}}
{{PAGESINNS:ns:R}}
{{PAGESINNS:2}} 
{{PAGESINNS:2:R}} 
disabled here
[MW1.7+] Returns the number of pages in the given namespace. Disabled by default, enable with $wgAllowSlowParserFunctions.

Page names and related info

Word Example Explanation
{{PAGENAME}} Magic words Returns the name of the current page, including all levels (Title/Subtitle).
{{PAGENAMEE}} Magic_words More URL-friendly percent encoded special characters (To use an articlename in an external link).
{{SUBPAGENAME}}
{{SUBPAGENAMEE}}
Magic words
Magic_words
[MW1.6+] Name of the current page, excluding parent pages ("Subtitle" on "Title/Subtitle") in namespaces supporting subpages, see Help:Link.
{{BASEPAGENAME}}
{{BASEPAGENAMEE}}
Magic words
Magic_words
[MW1.7+] The basename of a subpage ("Title" on "Title/Subtitle"), see Help:Link.
{{NAMESPACE}}
{{NAMESPACEE}}
Help
Help
Returns the name of the namespace the current page resides in.
{{FULLPAGENAME}}
{{FULLPAGENAMEE}}
Help:Magic words
Help:Magic_words
[MW1.6+] Shorthands for NAMESPACE+PAGENAME
{{TALKSPACE}}
{{TALKSPACEE}}
Help talk
Help_talk
[MW1.7+] Name of next odd namespace (e.g. 4 => 5)
{{SUBJECTSPACE}}
{{SUBJECTSPACEE}}
Help
Help
[MW1.7+] Name of last even namespace (e.g. 5 => 4)
{{ARTICLESPACE}}
{{ARTICLESPACEE}}
Help
Help
[MW1.7+] An alias for SUBJECTSPACE(E)
{{TALKPAGENAME}}
{{TALKPAGENAMEE}}
Help talk:Magic words
Help_talk:Magic_words
[MW1.7+] FULLPAGENAME in its TALKSPACE
{{SUBJECTPAGENAME}}
{{SUBJECTPAGENAMEE}}
Help:Magic words
Help:Magic_words
[MW1.7+] FULLPAGENAME in its SUBJECTSPACE
{{ARTICLEPAGENAME}}
{{ARTICLEPAGENAMEE}}
Help:Magic words
Help:Magic_words
[MW1.7+] An alias for SUBJECTPAGENAME(E)
{{REVISIONID}} 2243 [MW1.5+] The unique identifying number of a page, see Help:Diff.
{{REVISIONDAY}} Template:REVISIONDAY [MW1.8+] The day on which the page was last modified.
{{REVISIONDAY2}} Template:REVISIONDAY2 [MW1.8+] The day on which the page was last modified, but with a leading zero (01 .. 31).
{{REVISIONMONTH}} Template:REVISIONMONTH [MW1.8+] The month in which the page was last modified.
{{REVISIONYEAR}} Template:REVISIONYEAR [MW1.8+] The year in which the page was last modified.
{{REVISIONTIMESTAMP}} Template:REVISIONTIMESTAMP [MW1.8+] ISO 8601 time stamp, indicating when the page was last modified.
{{SITENAME}} GM Wiki Value of $wgSitename.
{{SERVER}} http://wiki.3400z24.com Value of $wgServer
{{SCRIPTPATH}} [MW1.5+] $wgScriptPath
{{SERVERNAME}} wiki.3400z24.com [MW1.5+] $wgServerName

Parser functions

For details see Help:Parser function.

Namespaces and URLs

Word Example Explanation
{{ns:}} {{ns:4}} = GM_Wiki
{{ns:project}} = GM_Wiki
Returns the name of a given namespace number.
{{localurl:x y @}}
{{localurle:x y @}}
{{localurl:a|b=c}}
/X_y_%40
/X_y_%40
/index.php?title=A&b=c
Returns the local URL of a page (might not exist). Optional query parameter, see Help:Variable.
{{urlencode:x y @}} x+y+%40 [MW1.7+] Encodes variable values for use in external links. [3]
{{anchorencode:x #y @}} Template:Anchorencode:x [MW1.8+] Encodes variable values for use in external links. [4]
{{fullurl:x y @}}
{{fullurle:x y @}}
{{fullurl:m:a|b=c}}
http://wiki.3400z24.com/X_y_%40
http://wiki.3400z24.com/X_y_%40
http://wiki.3400z24.com/index.php?title=M:a&b=c
[MW1.5+] Returns the full URL of a given page. Optional query parameter as for localurl:.

Formatting

Word Example Explanation
{{#language:}} {{#language:da}} = Dansk [MW1.7+] Native name of language code.
{{lc:}} {{lc:AbC dEf}} = abc def [MW1.5+] LowerCase
{{lcfirst:}} {{lcfirst:Ab Cd}} = ab Cd [MW1.5+] LC first char.
{{uc:}} {{uc:aBc DeF}} = ABC DEF [MW1.5+] UpperCase
{{ucfirst:}} {{ucfirst:aB cD}} = AB cD [MW1.5+] UC first char.
{{formatnum:}} {{formatnum:299792458}} = 299,792,458 [MW1.7+] Add decimal separators according to the wiki's default locale.
{{padleft:}}
{{padright:}}
{{padleft:bcd|6|a}} = Template:Padleft:bcd
{{padright:bcd|6|a}} = Template:Padright:bcd
[MW1.8+] Pads a string with a character to the specified width.

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}}
{{int:xyz}} Shorthand for {{MediaWiki:xyz}}, rendered as <xyz> if MediaWiki:xyz doesn't exist. See Help:MediaWiki namespace.
{{msg:xyz}} Try {{Template:xyz}} before magic word xyz, without this modifier it's the other way around. No additional effect if there is no template xyz.
{{msgnw:xyz}} The unevaluated wikitext is rendered. See msgnw.
{{raw:xyz}} [MW1.6+] Like {{msg:}} (unclear) [5]
{{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 [[Image:title.ext|modifier|...|modifier]] links. Some are mutually exclusive, and then the last specified wins.

Size

The last unrecognized modifier is used as caption for framed images or together with thumbnails. It's also used as description alt=text.

Word Usage Explanation
framed
frame
enframed
[[Image:Mediawiki.png|framed]] Places an image in a frame with a description. Uses original size.
thumbnail
thumb
[[Image:Mediawiki.png|thumbnail]] Modifies image size, sets it to dependant on user's favourite thumbnail size in their preferences.
thumb=xyz [[Image:Mediawiki.png|thumb=Wiki.png]] Manualthumb: instead of displaying an automatically-sized thumbnail for Mediawiki.png, display the image Wiki.png.
width px [[Image:Mediawiki.png|40px]] Scales image to given width  in pixels

Position

For details see Help:Images_and_other_uploaded_files

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

Word Usage Explanation
right [[Image:Mediawiki.png|right]] Modifies position, floats the image to the right.
left [[Image:Mediawiki.png|left]] Modifies position, floats the image to the left.
none [[Image:Mediawiki.png|none]] Explicitly states that the image should not float.
center
centre
[[Image:Mediawiki.png|center]] Modifies position, like none but centered.

Miscellany

Word Example Explanation
{{DISPLAYTITLE:xyz}} default disabled [MW 1.7+] Set the page's title [6], see $wgAllowDisplayTitle.
{{DIRMARK}}
{{DIRECTIONMARK}}

[MW1.7+] u+200E left to right or u+200D right to left mark
{{CONTENTLANGUAGE}} en [MW1.7+] Default content $wgLanguageCode
#redirect #REDIRECT [[target]]
at top of source page
Creates a redirect to another page.

Language-dependent word conversions

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

"Grammar" and "Plural" are language-dependent functions, defined in [10], [11], 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 project-dependent switch function, e.g. giving the first text if count = 1, the second if count = 2,3, or 4, and else the third. See also mediazilla:5805 for the use of "plural" in system messages.

See also

Template:Ph:Magic words

Links to other help pages

Help contents - all help pages
Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary | commons: | mw: | b: | s:
Versions of this help page (for other languages see below)
Meta | Wikinews | Wikipedia | Wikiquote | Wiktionary
Reading
Go | Search | Stop words | URL | Namespace | Page name | Section
Backlinks | Link | Piped link | Interwiki link | Redirect | Category | Image page
Logging in and preferences
Logging in | Preferences | User style
Editing
Advanced editing | Editing FAQ | Editing toolbar | Export | Import
Editing tips and tricks | Editing shortcuts
Tracking changes
Recent changes (enhanced) | Related changes | Watching pages | Diff
Page history | Edit summary | User contributions | Minor edit | Patrolled edit
Style & formatting
Wikitext examples | Wikitext reference | Reference card
HTML in wikitext | HTML elements
List | Table
Special input and output
Inputbox | Special characters | Displaying a formula |Images and other uploaded files | EasyTimeline
Advanced functioning
Template | Advanced templates | Parameter default | Variable | Magic word | Substitution | Array | Calculation
Page management
Starting a new page | Renaming (moving) a page | Maintenance | Merging and moving pages | Protecting pages
Resolving disputes | Deleting a page
Special pages
Talk page | Testing | Sandbox
Lists of resources
Categories | Lists of Categories | Copyrights | Infobox
Redirect | Reference Desk | Shortcuts | Stub types

Other languages: Template:H-langs:Magic words

Views
Personal tools