Help:Magic Words

From The Urban Dead Wiki
(Redirected from Magic Words)
Jump to navigationJump to search

Magic words are strings of text that the wiki associates with a return value or function, such as time, site details, or page names.

There are three general types of magic words:

  • Behavior switches: these are uppercase words surrounded by double underscores, e.g. __FOO__
  • Variables: these are uppercase words surrounded by double braces, e.g. {{FOO}}. As such, they look a lot like templates.
  • Parser functions: these take parameters and are either of the form {{foo:...}} or {{#foo:...}}.

Page-dependent magic words will affect or return data about the current page, even if the word is added through a transcluded template or included system message.

Behaviour switches

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.

Word Description
Table of contents
__NOTOC__ Hides the table of contents (TOC).
__FORCETOC__ Forces the table of content to appear at its normal position (above the first header).
__TOC__ Places a table of contents at the word's current position (overriding __NOTOC__). If this is used multiple times, the table of contents will appear at the first word's position.
Editing
__NOEDITSECTION__ Hides the section edit links beside headings.
__NEWSECTIONLINK__ Adds a link ("+") beside the "edit" tab for adding a new section on a non-talk page.
Categories
__NOGALLERY__ Used on a category page, replaces thumbnails in the category view with normal links.

Variables

Variables return information about the current page, wiki, or date. Their syntax is similar to templates.

Date & time

The following variables return the current date and time according to the user's timezone 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.

Variable Output Description
Year
{{CURRENTYEAR}} 2024 Year
Month
{{CURRENTMONTH}} 11 Month (zero-padded number)
{{CURRENTMONTHNAME}} November Month (name)
{{CURRENTMONTHNAMEGEN}} November Month (genitive form)
{{CURRENTMONTHABBREV}} Nov Month (abbreviation)
Day
{{CURRENTDAY}} 6 Day of the month (unpadded number)
{{CURRENTDAY2}} 06 Day of the month (zero-padded number)
{{CURRENTDOW}} 3 Day of the week (Sunday = 0 thru Saturday=6)
{{CURRENTDAYNAME}} Wednesday Day of the week (name)
Time
{{CURRENTTIME}} 01:55 Time (24-hour HH:mm format)
{{CURRENTHOUR}} 01 Hour (24-hour zero-padded number)
Other
{{CURRENTWEEK}} 45 Week (number)
{{CURRENTTIMESTAMP}} 20241106015547 YYYYMMDDHHmmss timestamp

The following variables do the same as the above, but using the server's time (either UTC or BST (UTC+1) depending on daylight savings)

  • {{LOCALYEAR}}
  • {{LOCALMONTH}}
  • {{LOCALMONTHNAME}}
  • {{LOCALMONTHNAMEGEN}}
  • {{LOCALMONTHABBREV}}
  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}
  • {{LOCALDAYNAME}}
  • {{LOCALTIME}}
  • {{LOCALHOUR}}
  • {{LOCALWEEK}}
  • {{LOCALTIMESTAMP}}

Technical metadata

Revision variables return data about the latest edit to the current page, even if viewing an older version of the page.

Variable Output Description
Site
{{SITENAME}} The Urban Dead Wiki The wiki's site name
{{SERVER}} //wiki.urbandead.com domain URL
{{SERVERNAME}} wiki.urbandead.com domain name
{{CURRENTVERSION}} 1.39.1 The wiki's MediaWiki version.
Latest revision to current page
{{REVISIONID}} 2041895 Unique revision ID
{{REVISIONDAY}} 19 Day edit was made (unpadded number)
{{REVISIONDAY2}} 19 Day edit was made (zero-padded number)
{{REVISIONMONTH}} 11 Month edit was made (unpadded number)
{{REVISIONYEAR}} 2012 Year edit was made
{{REVISIONTIMESTAMP}} 20121119043404 Timestamp as of time of edit

Statistics

Numbers returned by these variables normally contain separators (commas or spaces, depending on the local language), but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}} → 152,321 and {{NUMBEROFPAGES:R}} → 152321).

Variable Output Description
Entire wiki
{{NUMBEROFPAGES}} 152,321 Number of wiki pages.
{{NUMBEROFARTICLES}} 19,388 Number of pages in main namespace without Main Page.
{{NUMBEROFFILES}} 22,071 Number of uploaded files.
{{NUMBEROFUSERS}} 51,331 Number of registered users.
{{NUMBEROFADMINS}} 7 Number of sysops.
{{PAGESINCATEGORY:Guides}} 132 Number of pages in the specified category.

Page names

Variable Output Description
{{FULLPAGENAME}} Help:Magic Words Namespace and page title. ("Help:Title/Page/Subpage" on "Help:Title/Page/Subpage").
{{PAGENAME}} Magic Words Page title excluding namespace. ("Title/Page/Subpage" on "Help:Title/Page/Subpage").
{{BASEPAGENAME}} Magic Words Page title excluding the current subpage and namespace ("Title/Page" on "Help:Title/Page/Subpage").
{{SUBPAGENAME}} Magic Words The subpage title ("Subpage" on "Help:Title/Page/Subpage").
{{SUBJECTPAGENAME}} Help:Magic Words The namespace and title of the associated content page.
{{TALKPAGENAME}} Help talk:Magic Words The namespace and title of the associated talk page.

The {{BASEPAGENAME}} and {{SUBPAGENAME}} magic words only work in namespaces that have subpages enabled.

The following are URL-encoded equivalents:

  • {{FULLPAGENAMEE}}
  • {{PAGENAMEE}}
  • {{BASEPAGENAMEE}}
  • {{SUBPAGENAMEE}}
  • {{SUBJECTPAGENAMEE}}
  • {{TALKPAGENAMEE}}

Namespaces

Variable Output Description
{{NAMESPACE}} Help Namespace (name)
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Help
Help
Name of the associated content namespace
{{TALKSPACE}} Help talk Name of the associated talk namespace

The following are URL-encoded equivalents:

  • {{NAMESPACEE}}
  • {{SUBJECTSPACEE}}
  • {{TALKSPACEE}}

Parser functions

Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is usually prefixed with a hash to distinguish them from possible templates)

This page only describes parser functions that are integral to the MediaWiki software. This wiki does not have the Parser functions extension.

URL data

Parser function Input → Output Description
{{localurl:page name}}
{{localurl:page name|query string}}
{{localurl:Help:Magic Words}} → /index.php/Help:Magic_Words
{{localurl:Help:Magic Words|printable=yes}} → /index.php?title=Help:Magic_Words&printable=yes
The relative path to the title.
{{fullurl:page name}}
{{fullurl:page name|query_string}}
{{fullurl:Help:Magic Words}} → //wiki.urbandead.com/index.php/Help:Magic_Words

{{fullurl:Help:Magic Words|action=edit}} → //wiki.urbandead.com/index.php?title=Help:Magic_Words&action=edit

The absolute path to the title.
{{urlencode:string}} {{urlencode:x y z}} → x+y+z The input encoded for use in URLs.
{{anchorencode:string}} {{anchorencode:x y z}} → x_y_z The input encoded for use in URL section anchors (after the '#' symbol in a URL).

Namespaces

{{ns:}} returns the localized name for the namespace with that index.

Content namespaces Talk namespaces
Usage Output Usage Output
{{ns:-2}} or {{ns:Media}} Media {{ns:-1}} or {{ns:Special}} Special
{{ns:0}} {{ns:1}} or {{ns:Talk}} Talk
{{ns:2}} or {{ns:User}} User {{ns:3}} or {{ns:User talk}} User talk
{{ns:4}} or {{ns:Project}} UDWiki {{ns:5}} or {{ns:Project talk}} UDWiki talk
{{ns:6}} or {{ns:File}} or {{ns:Image}} File {{ns:7}} or {{ns:File talk}} or {{ns:Image talk}} File talk
{{ns:8}} or {{ns:MediaWiki}} MediaWiki {{ns:9}} or {{ns:MediaWiki talk}} MediaWiki talk
{{ns:10}} or {{ns:Template}} Template {{ns:11}} or {{ns:Template talk}} Template talk
{{ns:12}} or {{ns:Help}} Help {{ns:13}} or {{ns:Help talk}} Help talk
{{ns:14}} or {{ns:Category}} Category {{ns:15}} or {{ns:Category talk}} Category talk

Formatting

Usage Input → Output Description
{{lc:string}} {{lc:TEXT TRANSFORM}} → text transform The lowercase input.
{{lcfirst:string}} {{lcfirst:TEXT TRANSFORM}} → tEXT TRANSFORM The input with the very first character lowercase.
{{uc:string}} {{uc:text transform}} → TEXT TRANSFORM The uppercase input.
{{ucfirst:string}} {{ucfirst:text transform}} → Text transform The input with the very first character uppercase.
{{formatnum:unformatted num}}
{{formatnum:formatted num|R}}
{{formatnum:-987654321.654321}} → −987,654,321.654321 Formats a number.
{{padleft:xyz|stringlength}}
{{padleft:xyz|strlen|char}}
{{padleft:xyz|5}} → 00xyz
{{padleft:xyz|5|_}} → __xyz
Inserts a string of padding characters (character chosen in third parameter; default '0') of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. {{padleft:44|3|0}} produces 044.
{{padright:xyz|stringlength}}
{{padright:xyz|strlen|char}}
{{padright:xyz|5}} → xyz00
{{padright:xyz|5|_}} → xyz__
Identical to padleft, but adds padding characters to the right side.
{{plural:2|is|are}} {{plural:1|is|are}} → is
{{plural:2|is|are}} → 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

Editing Help
Basic Editing

Advanced Editing

Advanced Timesavers

Page Tricks

Communicating your Edits

Miscellaneous

Policies and Guidelines
Guidelines

Policy Documents