Help:Magic words

From Fanon Wiki
Logo mono black.png
This is one of Fanon Wiki's help pages and is meant to aid users by improving their ability to positively contribute to the wiki. Expanding pages such as this with additional information is always welcome.
Logo mono black.png

Magic words are functions in MediaWiki that either modify the page and are called with double underscores on each side (officially referred to as "behavior switches") and things that return information and are called similarly to templates (officially referred to as "variables", ones that can take parameters can also be called "parser functions"). This is a list of helpful magic words and descriptions. Functions marked as expensive use more server resources and should not be used unless neccesary. Behavior switches are typically used directly on pages (although can be used on templates, such as __EXPECTUNUSEDCATEGORY__ on {{Not unused}}, and variables and parser functions are typically used on templates. Variables and parser functions can also be substituted by putting subst: before the name of it but after the opening braces. This is also not a comprehensive list, and only includes the ones that are simpler and/or more likely to be used here. For a full list and more in-depth explanations, see the documentation.

Behavior switches

Name Effect
__NOTOC__ Makes the table of contents disappear
__FORCETOC__ Overrides and undoes __NOTOC__
__TOC__ Makes the table of contents appear in a different location
__NOEDITSECTION__ Makes a page section not be editable without editing the whole page
__NOGALLERY__ Makes files appear as normal links in categories
__HIDDENCAT__ Makes a category hidden and not appear to users unless they change a setting in their user preferences
__EXPECTUNUSEDCATEGORY__ Makes a category not appear unused. Should only be used on maintenance categories.
__NOINDEX__ Hides the page from search engine results


All time-related variables use UTC and may not be fully accurate due to server-side caching.

Base MediaWiki variables and parser functions
Name Returns
{{CURRENTYEAR}} Year as numerals
{{CURRENTMONTH}} Month as numerals with leading zeroes added (adding 1 to the end removes the leading zeroes, adding NAME to the end makes it the name, adding ABBREV makes it the name abbreviation)
{{CURRENTDAY}} Day of the month (adding 2 to the end adds leading zeroes)
{{CURRENTDOW}}/{{CURRENTDAYNAME}} Number/name of the day of the week
{{CURRENTTIME}} 24-hour time as HH:mm
{{CURRENTHOUR}} Hour with leading zeroes
{{CURRENTWEEK}} Current week of the year
{{SITENAME}} Name of the wiki
{{NUMBEROFx}} Number of x on the wiki:
  • PAGES returns all pages
  • ARTICLES returns content pages
  • FILES returns files
  • EDITS returns edit count
  • USERS returns registered user count
  • ADMINS returns number of administrators
  • ACTIVEUSERS returns list of people who did something in the last 30 days
{{xPAGENAME}} Returns the name of the current page, containing the parts x
  • Blank returns the full name without the namespace
  • FULL returns the full name including the namespace
  • BASE returns the page that it is a subpage of
  • ROOT returns the root page that the page is a subpage of
  • SUB returns the subpage name without any of the preceding part
  • ARTICLE or SUBJECT returns the non-talk version on a talk page
  • TALK returns the talk page of a non-talk page

This is not affected by DISPLAYTITLE

{{NAMESPACE}} The namespace of the page. Adding NUMBER to the end makes it the id.
{{!}} The pipe character |, for table markup within templates.

Parser functions

Base MediaWiki parser functions
Name Effect
{{PAGESINCATEGORY:name|modifier}} EXPENSIVE. Returns the number of pages in the category name. modifier can be set to all, pages, subcats (subcategories), or files.
{{DISPLAYTITLE:name}} Makes the page title display as something different than the page URL.
{{localurl:name|query}} Returns the url path (not including domain name, replace local with full for domain name and interwiki support and replace it with canonical to include https:) of a page on the wiki. query can be set to a query that can be performed in the url (such as action=edit
{{ns:name/id}} The name of the namespace specified in name/id
{{lc:text}} text in all lowercase
{{uc:text}} text in all uppercase
Extension parser functions
Name Effect
{{#expr:math}} Does whatever mathematical formula is input. Also supports boolean inputs.
{{#if:test|not empty|empty}} Returns empty if test is empty or whitespace and not empty if not.
{{#ifeq:test1|test2|same|different}} Returns same if test1 and test2 match and different otherwise
{{#switch:test|1=one|2|1+1=two|#default=three}} Returns one if test is 1 and two if test is 2 or 1+1, and three if it is none of them. The values to check for can be repeated indefinitely (in theory).