Help:Magic words
| 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 two 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.
Contents |
[edit] Variables
- For details see Help:Variable
[edit]
| 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 articlename in an external link). |
| {{BASEPAGENAME}} {{BASEPAGENAMEE}} |
Magic words |
Anonymous user/sandbox |
[MW1.7+] The basename of a subpage ("Title/Other" on "Title/Other/Subtitle"), see Help:Link. |
| {{SUBPAGENAME}} {{SUBPAGENAMEE}} |
Magic words |
my page |
[MW1.6+] Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages, see Help:Link. |
| {{NAMESPACE}} {{NAMESPACEE}} |
Help |
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 |
|||
| {{FULLPAGENAME}} {{FULLPAGENAMEE}} |
Help:Magic words |
User:Anonymous user/sandbox/my page |
[MW1.6+] Shorthands for NAMESPACE+PAGENAME |
User talk:Anonymous user/sandbox/my page |
|||
| {{TALKSPACE}} {{TALKSPACEE}} |
Help talk |
User talk |
[MW1.7+] Name of next odd namespace (e.g. 4 => 5) |
| {{SUBJECTSPACE}} {{SUBJECTSPACEE}} |
Help |
User |
[MW1.7+] Name of last even namespace (e.g. 5 => 4) |
| {{ARTICLESPACE}} {{ARTICLESPACEE}} |
Help |
User |
[MW1.7+] An alias for SUBJECTSPACE(E) |
| {{TALKPAGENAME}} {{TALKPAGENAMEE}} |
Help talk:Magic words |
User talk:Anonymous user/sandbox/my page |
[MW1.7+] FULLPAGENAME in its TALKSPACE |
| {{SUBJECTPAGENAME}} {{SUBJECTPAGENAMEE}} |
Help:Magic words |
User:Anonymous user/sandbox/my page |
[MW1.7+] FULLPAGENAME in its SUBJECTSPACE |
| {{ARTICLEPAGENAME}} {{ARTICLEPAGENAMEE}} |
Help:Magic words |
User:Anonymous user/sandbox/my page |
[MW1.7+] An alias for SUBJECTPAGENAME(E) |
| {{REVISIONID}} | 3670147 |
N/A | [MW1.5+] The unique identifying number of a page, see Help:Diff. Note that when editing a page, this value is null. |
| {{REVISIONDAY}} | 21 |
N/A | [MW1.8+] The day on which the page was last modified. |
| {{REVISIONDAY2}} | 21 |
N/A | [MW1.8+] The day on which the page was last modified, but with a leading zero (01 .. 31). |
| {{REVISIONMONTH}} | 04 |
N/A | [MW1.8+] The month in which the page was last modified. |
| {{REVISIONYEAR}} | 2012 |
N/A | [MW1.8+] The year in which the page was last modified. |
| {{REVISIONTIMESTAMP}} | 20120421160611 |
N/A | [MW1.8+] ISO 8601 time stamp, indicating when the page was last modified. |
| {{SITENAME}} | Meta |
Value of $wgSitename. | |
| {{SERVER}} | //meta.wikimedia.org | Value of $wgServer | |
| {{SCRIPTPATH}} | /w |
[MW1.5+] $wgScriptPath | |
| {{SERVERNAME}} | meta.wikimedia.org |
[MW1.5+] $wgServerName | |
[edit] 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.
[edit] 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 1px 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 below). |
| thumb=xyz | [[File:Mediawiki.png|thumb=Wiki.png]] | Manualthumb: 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. |
[edit] 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 above) 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. |
[edit] 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}} |
|
[MW1.7+] u+200E left to right or u+200D right to left mark |
| {{CONTENTLANGUAGE}} | en |
[MW1.7+] code of the site's default interface language ($wgLanguageCode) |
| {{DEFAULTSORT:xyz}} | no inline output | [MW1.10+] Sets a default category sort key for the whole current page (also applying for category tags before this tag)[1]. |
| #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.
[edit] See also
- ParserFunctions #expr:, #if:, #ifeq:, etc.
- mw:Manual:Magic words
- Source for Language.php
- Source for MagicWord.php
- Adding parser functions
- mw:Extension:Variables : MediaWiki extension to add new magic words
[edit] Notes and references
- ↑ "Technology report", en-Wikipedia Signpost, January 2007
[edit] 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 below)
- Meta | Wikinews | Wikipedia | 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 | Sandbox | Legal issues for editors
| Language: | English • Dansk • Español • Français • 日本語 • Português |
|---|