Help:Magic words

From Avon Lake Wiki
Jump to: navigation, search

Magic words are strings of text that MediaWiki 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}}.
  • Parser functions: these take parameters and are either of the form {{foo:...}} or {{#foo:...}}.

Behavior switches

A behavior switch controls the layout or behavior 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 contents to appear at its normal position (before the first header, overriding __NOTOC__).
__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.
__NONEWSECTIONLINK__ Removes the link beside the "edit" tab on pages in talk namespaces.
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. There is a limit to the number of variables marked as "[expensive]" per page.

Date and time

The following variables labeled current return the current date and time in UTC.
The following variables labeled local return the current date and time in eastern time.

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}} 2019 Year
{{LOCALYEAR}} 2019
Month
{{CURRENTMONTH}} 02 Month (zero-padded number)
{{LOCALMONTH}} 02
{{CURRENTMONTH1}} 2 Month (unpadded number)
{{LOCALMONTH1}} 2
{{CURRENTMONTHNAME}} February Month (name)
{{LOCALMONTHNAME}} February
{{CURRENTMONTHNAMEGEN}} February Month (genitive form)
{{LOCALMONTHNAMEGEN}} February
{{CURRENTMONTHABBREV}} Feb Month (abbreviation)
{{LOCALMONTHABBREV}} Feb
Day
{{CURRENTDAY}} 16 Day of the month (unpadded number)
{{LOCALDAY}} 16
{{CURRENTDAY2}} 16 Day of the month (zero-padded number)
{{LOCALDAY2}} 16
{{CURRENTDOW}} 6 Day of the week (unpadded number), 0 (for Sunday) through 6 (for Saturday)
{{LOCALDOW}} 6
{{CURRENTDAYNAME}} Saturday Day of the week (name)
{{LOCALDAYNAME}} Saturday
Time
{{CURRENTTIME}} 20:45 Time (24-hour HH:mm format)
{{LOCALTIME}} 15:45
{{CURRENTHOUR}} 20 Hour (24-hour zero-padded number)
{{LOCALHOUR}} 15
Other
{{CURRENTWEEK}} 7 Week (number)
{{LOCALWEEK}} 7
{{CURRENTTIMESTAMP}} 20190216204506 YYYYMMDDHHmmss timestamp
{{LOCALTIMESTAMP}} 20190216154506

Technical metadata

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

Variable Output Description
Page
{{PAGEID}} 183 Returns the page identifier.
{{DISPLAYTITLE:title}} Change the current page's title header. The value must be equivalent to the default title: only capitalization changes to certain parts of the title and replacing spaces with underscores are allowed.

Statistics

Variable Output Description
{{NUMBEROFPAGES}} 115 Number of wiki pages.
{{NUMBEROFARTICLES}} 66 Number of pages in namespace.
{{NUMBEROFFILES}} 2 Number of uploaded files.
{{NUMBEROFEDITS}} 519 Number of wiki edits.
{{NUMBEROFUSERS}} 14 Number of registered users.
{{NUMBEROFADMINS}} 3 Number of users in the sysop group.
{{NUMBEROFACTIVEUSERS}} 0 Number of active users, based on the criteria used in Special:Statistics.
{{PAGESINCATEGORY:categoryname}}

{{PAGESINCAT:categoryname}}

18

18

[ Expensive] Number of pages (including subcategories and files) in the given category. (Category:Help used for demonstration)
{{PAGESINCATEGORY:categoryname|all}}

{{PAGESINCATEGORY:categoryname|pages}}
{{PAGESINCATEGORY:categoryname|subcats}}
{{PAGESINCATEGORY:categoryname|files}}

18

17
1
0

[ Expensive]

Respectively, the number of

  • all pages
  • ordinary pages (excluding subcategories and files)
  • subcategories or
  • files

in the given category. (Category:Help used for demonstration)

Namespaces

Variable Output Description
{{NAMESPACE}} Help Name of the page's namespace
{{NAMESPACENUMBER}} 12 ID of the page's namespace
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Help
Help
Name of the associated content namespace
{{TALKSPACE}} Help talk Name of the associated talk namespace

Other

Variable Output Description
{{!}} | Used to include a pipe character as content in a table cell.

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).

URL data

Parser function Input → Output Description
{{fullurl: page name}} {{fullurl:Main_Page}}
https://www.alwiki.net/wiki/Main_Page
A protocol-relative path to the title. Note: Unbracketed protocol-relative links are not automatically linked.
{{filepath: file name}}
{{filepath:file name|nowiki}}
{{filepath:file name|thumbnail_size}}
{{filepath:Wiki.png}}

{{filepath:Wiki.png|nowiki}}

{{filepath:Example.svg|300}}
https://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Example.svg/300px-Example.svg.png

A protocol-relative path to the full size or thumbnail of a media file.