Help:Magic words

From Wikipedia of the Dark Brotherhood, an online Star Wars Club
Revision as of 06:43, 23 May 2011 by Orv Dessrx (talk | contribs) (import from google cache)
<img alt="" src="/code/images/thumb/8/8e/1leftarrow.png/16px-1leftarrow.png" width="16" height="16" border="0"> Help:Contents

Magic words (which include parser functions, variables and behavior switches) are features of wikitext that enable various instructions to be given to the MediaWiki software (for example, to suppress or position the table of contents), or else serve to produce variable output, as is often required in templates.


General information

There are three types of magic words:


  • Behavior switches: uppercase words surrounded by double underscores, e.g. , or keywords using parser function syntax
  • Variables: uppercase words surrounded by double braces, e.g. Magic words (thus resembling templates)
  • Parser functions: keywords (some beginning #) in double braces with parameters after a colon, e.g. 4

Some magic words are case-insensitive, but not all. Whitespace is stripped from the start and end of keywords and parameters, as in template syntax.

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.


Behavior switches

For documentation, refer to the Behavior Switches section of the MediaWiki page.


  • (can appear anywhere in the wikitext; suppresses the table of contents)
  • (can appear anywhere in the wikitext; makes a table of contents appear in its normal position above the first header)
  • (places a table of contents at the word's position)
  • (hides the section edit links beside headings)
  • (adds a "+" link for adding a new section on a non-"Talk" page)
  • (removes the "+" link on "Talk" pages)
  • (on a category page, replaces thumbnails with normal links)
  • (on a category page, makes it a hidden category)
  • (tells search engines to index the page)
  • (tells search engines not to index the page)
  • (changes the displayed form of the page title)
  • (sets a default category sort key)

Variables

For documentation, refer to the Variables section of the MediaWiki page.


  • Help:Magic words (page title including namespace)
  • Magic words (page title excluding namespace)
  • Magic words (page title excluding subpage and namespace)
  • Magic words (subpage part of title)
  • Help:Magic words (associated non-talk page)
  • Help talk:Magic words (associated talk page)
  • Help (namespace of current page)
  • Help, Help (associated non-talk namespace)
  • Help talk (associated talk namespace)
  • Help:Magic_words, Help etc. (URL-encoded equivalents)

The above can all take a parameter, to operate on a page other than the current page.


  • Wikipedia of the Dark Brotherhood, an online Star Wars Club (Wikipedia of the Dark Jedi Brotherhood, an online Star Wars Club)
  • https://wiki.darkjedibrotherhood.com (http://en.wikipedia.org)
  • wiki.darkjedibrotherhood.com (wiki.darkjedibrotherhood.com)
  • (/code)
  • 1.41.0 (current MediaWiki version)
  • 89995 (latest revision to current page)
  • 23, 23, 05, 2011, 20110523064329, Orv Dessrx (date, time, editor at last edit)
  • 2024, 05, May, May, 25, 25, 6, Saturday, 03:32, 03, 21, 20240525033233 (current date/time variables)
  • 2024 etc. (as above, based on site's local time)
  • 18,285, 4,083, 7,567, 200,155, Template:NUMBEROFVIEWS, 988, 17, 30 (statistics on English Wikipedia; add :R to return numbers without commas)

Parser functions

These are documented at the main documentation page unless otherwise stated.


Metadata

  • 0 (size of page in bytes)
  • (protection level for given action on the current page)
  • 0 (number of pages in the given category)
  • 0 (number of users in a specific group)

Add |R to return numbers without commas.


Formatting

  • string (convert to lower case)
  • string (convert first character to lower case)
  • STRING (convert to upper case)
  • string (convert first character to upper case)
  • unformatted num (format a number with comma separators; add |R to unformat a number)
  • date (formats a date according to user preferences; a default can be given as a second parameter for users without date preference).
  • xyz, xyz (pad with zeros to the right or left; an alternative padding string can be given as a third parameter)
  • are (produces alternative text according to whether n is greater than 1)
  • Error: Invalid time. (for date/time formatting; also #timel for local time. Covered at the extension documentation page.)

Paths

Conditional expressions

These are covered at the extension documentation page (above). Some parameters are optional.


  • Expression error: Unrecognized punctuation character "'". (evaluates the given expression; see Help:Calculation on Wookieepedia)
  • value if non-empty (selects one of two values based on whether the test string is empty)
  • value if unequal (selects one of two values based on whether the test strings are equal – numerically if applicable)
  • value if correct (selects value based on whether the test string generates a parser error)
  • Expression error: Unrecognized punctuation character "'". (selects value based on evaluation of expression)
  • value if doesn't exist (selects value depending on whether a page title exists)
  • default (provides alternatives based on the value of the test string)

For the use of these functions in tables, see Conditional tables.