Help:Magic Words

The UESPWiki – Your source for The Elder Scrolls since 1995
Help
Jump to: navigation, search

This is a summary of magic words that are unique to UESP. All of the standard MediaWiki magic words are also available, as listed at Wikimedia. Most of these magic words are added by one of two UESP custom extensions, namely UespCustomCode and MetaTemplate. More details on these magic words may be provided on the extension documentation pages.

Variables[edit]

Page Names[edit]

Word Examples, for pages named:
Oblivion:An Unexpected Voyage (quest)/Description
Tes3Mod:Tamriel Rebuilt/To Catch A Spy
Explanation
{{CORENAME}}
{{CORENAME:arg}}
(UespCustomCode)
An Unexpected Voyage (quest)
To Catch A Spy
Generally, this variable is the same as {{SUBPAGENAME}}, i.e., it is the article name excluding all parent pages. However, if {{SUBPAGENAME}} is equal to "Description", "Author", "Desc", or "Direction", then it is the name of the immediate parent of the page.

This should be the portion of the page name that is most relevant for describing the page.

Note: there should no longer be any reason to use CORENAME with no arguments on this wiki, as the subpage names it handles are no longer in use. It can be replaced with {{SUBPAGENAME}} instead.

{{LABELNAME}}
{{LABELNAME:arg}}
(UespCustomCode)
An Unexpected Voyage
To Catch A Spy
This variable is the same as {{CORENAME}}, but any disambiguation-style parentheses are removed. Specifically, any words contained in parentheses at the end of the pagename are removed, along with any whitespace. It is equivalent to {{#label:{{CORENAME}}}}

This is how the pagename would appear on a link label, e.g., how it would appear in a link entered as [[{{CORENAME}}]].

{{SORTABLECORENAME}}
{{SORTABLECORENAME:arg}}
(UespCustomCode)
Unexpected Voyage (quest), An
To Catch A Spy
This variable is the same as {{CORENAME}}, but converted into a format appropriate for sorting the pagename alphabetically. Specifically, the articles "A", "An", and "The" are removed from the front of the name, and appended to the end of the name with a comma. It is equivalent to {{#sortable:{{CORENAME}}}}

This should generally be the appropriate variable to use for any category sortkeys, or for DEFAULTSORT.

Word Example, for a template named:
Template:Example
Explanation
{{PAGENAME0}}
(MetaTemplate)
Example This variable is the same as the standard magic word {{PAGENAME}}, except it always returns the name of the page where the tag appears -- not the name of the displayed article. Therefore, if Template:Example contained the tag {{PAGENAME0}}, that tag would always print "Example", no matter what page the template is called from or included into.
{{FULLPAGENAME0}}
(MetaTemplate)
Template:Example This variable is the same as the standard magic word {{FULLPAGENAME}}, except it always returns the full name of the page where the tag appears, comparable to {{PAGENAME0}}.
{{PAGENAMEx:arg}}
(MetaTemplate)
Example This variable can be used to obtain the {{PAGENAME}} of any article in the template stack; arg is a numeric value specifying the requested article.
  • If arg is 0 (e.g., {{PAGENAMEx:0}}), it provides the name of the template where the tag appears, equivalent to {{PAGENAME0}}
  • If arg is negative (e.g., {{PAGENAMEx:-1}}), it counts backwards through the template stack from the template where the tag appears. So arg=-1 provides the name of the article that called {{PAGENAME0}}; arg=-2 provides the name of the template that called {{PAGENAMEx:-1}}
  • If arg is positive (e.g., {{PAGENAMEx:2}}, it counts forwards through the template stack starting from the article whose text is being generated. So arg=1 is always the same as {{PAGENAME}}; arg=2 is the template called by {{PAGENAME}}

If the requested arg is out of range, a blank string is returned.

{{FULLPAGENAMEx:arg}}
(MetaTemplate)
Template:Example This variable can be used to obtain the {{PAGENAME}} of any article in the template stack, comparable to {{PAGENAMEx:arg}}; arg is a numeric value specifying the requested article.

Namespace[edit]

Two namespace-related variables are added by MetaTemplate

Word Example, for a template named:
Template:Example
Explanation
{{NAMESPACE0}} Template This variable is the same as the standard magic word {{NAMESPACE}}, except it always returns the namespace of the page where the tag appears, comparable to {{PAGENAME0}}.
{{NAMESPACEx:arg}} Template This variable can be used to obtain the {{NAMESPACE}} of any article in the template stack, comparable to {{PAGENAMEx:arg}}; arg is a numeric value specifying the requested article.

The rest of the namespace-related variables are all added by the UespNamespace class in UespCustomCode. In all cases:

  • The definitions of the namespaces are provided by MediaWiki:uespnamespacelist (which can be updated by the site's admins). The definition list can include both true namespaces and mods which contain articles that are subpages of the mod's main page (e.g., Tes3Mod:Tamriel Rebuilt)
  • The variables are designed so that mods listed in uespnamespacelist can be treated as if they were true namespaces, in particular within templates.
  • These variable names must be upper case. Either an underscore (_) or a space ( ) can be used interchangeably.
  • There are three possible ways that these magic words can identify the requested namespace:
    1. Any of the magic words can be called with an argument ("arg" in the following examples) which specifies the desired namespace. The argument can be the basic name of the namespace ({{NS_BASE}}) or the ID of the namespace ({{NS_ID}}). This option overrides any other options.
    2. If the magic word is called without an argument, then the code checks to see whether the template variables ns_base or ns_id have been set (the variables must be all lowercase; ns_base takes precedence over ns_id). If so, these variables are used to determine the namespace.
    3. If neither of the above conditions is met, then the default behavior is to automatically identify the namespace (or mod) for the article, and return values appropriate for that namespace. For talk page articles, the corresponding SUBJECTSPACE is always used, instead of the talk namespace.
Word Examples:
SI
TR3
Explanation
{{NS_BASE}}
{{NS_BASE:arg}}
Shivering
Tes3Mod:Tamriel Rebuilt
Returns the basic name of the subject namespace
  • For standard namespaces, this variable is equivalent to {{SUBJECTSPACE}}.
  • For mods, this variable is equivalent to {{SUBJECTSPACE}}:{{MOD_NAME}}
{{MOD_NAME}}
{{MOD_NAME:arg}}

Tamriel Rebuilt
The name of the mod
  • For standard namespaces, this variable is blank (an empty string)
  • For mods, it is the article name of the mod's main article.
{{NS_FULL}}
{{NS_FULL:arg}}
Shivering:
Tes3Mod:Tamriel Rebuilt/
Returns the name of the namespace, including whatever punctuation is necessary before appending an article name.
  • For true namespaces, this is equivalent to {{NS_BASE}}: (a colon is added to {{NS_BASE}})
  • For mods, it is equivalent to {{NS_BASE}}/ (a slash is added to {{NS_BASE}})
{{NS_ID}}
{{NS_ID:arg}}
SI
TR3
Returns the ID used as a shorthand for this namespace. For most games, it is a two-letter ID. The value returned by {{NS_ID}} is always all uppercase characters, but lowercase IDs will also be recognized as input to the namespace variables.
{{NS_PARENT}}
{{NS_PARENT:arg}}
Oblivion
Morrowind
Returns the basic name of the parent namespace, i.e., the primary game, rather than the game expansion. This is normally the namespace which contains generic documentation, such as information about the game's races and attributes.
  • For standalone games, it is equivalent to {{NS_BASE}}
  • For expansions or mods, it is the standalone game necessary to run the expansion/mod.
{{NS_NAME}}
{{NS_NAME:arg}}
Shivering Isles
Tamriel Rebuilt
The descriptive name for the namespace; the name used for the main article describing the namespace. By default, this is equivalent to {{NS_BASE}}, unless a more appropriate value is specified in the namespace's definition.
{{NS_MAINPAGE}}
{{NS_MAINPAGE:arg}}
Shivering:Shivering Isles
Tes3Mod:Tamriel Rebuilt
The location of the namespace's main page. By default, this is equivalent to {{NS_FULL}}{{NS_NAME}}, unless a more appropriate value is specified in the namespace's definition.
{{NS_CATEGORY}}
{{NS_CATEGORY:arg}}
Shivering
Tes3Mod-Tamriel Rebuilt
The prefix used for this namespace on category pages. By default, this is equivalent to {{NS_BASE}}, unless a more appropriate value is specified in the namespace's definition.
{{NS_TRAIL}}
{{NS_TRAIL:arg}}
Shivering Isles
Tes3Mod: Tamriel Rebuilt
The prefix used for this namespace in breadcrumb trails, i.e., a full link to the namespace's main page, plus optionally links to any other relevant articles for the namespace. By default, this is equivalent to [[{{NS_MAINPAGE}}|{{NS_NAME}}]], unless a more appropriate value is specified in the namespace's definition.

Other[edit]

The NESTLEVEL magic word is added by the MetaTemplate Extension

Word Examples Explanation
{{NESTLEVEL}} 0
2
This variable tells you whether a template is being called directly or whether it's being called from another page. When an article is being parsed, NESTLEVEL always starts at 0 (while processing any content that directly appears on the article). NESTLEVEL increases by 1 each time a template called, and decreases back to the original value when the processing of that template is complete.

For example: Oblivion:Anga calls Template:Place Summary, which in turn calls Template:Map Link. When the wiki generates the displayed version of Anga, NESTLEVEL would be 0 if called from within Anga, 1 if called from within Place Summary, and 2 if called from within Map Link. However, when the wiki generates the page displayed at Template:Map Link, the same call to NESTLEVEL would produce 0.

Parser Functions[edit]

Word Example Explanation
{{#label:text}} {{#label:Pagename (quest)}}=Pagename
{{#label:Pagename, quest}}=Pagename, quest
[UespCustomCode] Removes any words in parentheses that are located at the end of the string, and also removes any whitespace preceding the parentheses. This is the same way that the pagename would by default appear in a link label.

Note that unlike standard MediaWiki configurations, words following a comma in a page title are not removed, either when generating link labels or when using the {{#label:}} function.

{{#sortable:text}} {{#sortable:A Pagename}}=Pagename, A
{{#sortable:Another Pagename}}=Another Pagename
[UespCustomCode] If the pronouns "A", "An", or "The" appear at the start of the string, they are moved to the end of the string. In other words, the string is converted to a version suitable for use in sorting alphabetically.

{{#include:file1[|file2]}}

{{#include:Lore:Altmer}}={{Lore:Altmer}}
{{#include:Lore:NotAPage}}=
[MetaTemplate] Given a list of filenames, #include finds the first one that exists and includes (transcludes) that article's contents. Only one article is included for a given #include function; if multiple valid filenames are provided, the others are ignored. If no valid filenames are provided, #include returns an empty string.

See MetaTemplate for details.

{{#splitargs:template|nargs}}

{{#splitargs:ID|1|val1|val2}}={{ID|val1}}{{ID|val2}} [MetaTemplate] Calls template repeatedly, each time passing template the next nargs arguments, until all available arguments are used up. The arguments are either taken from the parent template's arguments or, if those empty, they are taken from the rest of the arguments passed to #splitargs.

See MetaTemplate for details.

{{#trimlinks:text}} {{#trimlinks:A Link}}=A Link [MetaTemplate] Any internal links within the provided text are removed; the links are replaced by the label that would have been displayed as part of the link.
{{#pickfrom:npick|arg1|arg2}} [MetaTemplate] Randomly picks npick items from the subsequent list of arguments and prints them.
{{#listsaved:template|arg1=value1}} [MetaTemplate] Finds all articles with #saved data that match a set of criteria, then calls template for each of those articles. Each time template is called, it can be passed any requested #saved values. All of the resulting text is printed.
{{#ifexistx:pagename|true|false}} [MetaTemplate] Identical to standard {{#ifexist}} function from ParserFunctions, except it does not make an entry appear in Whatlinkshere for the tested pagename.

Parser Subroutines[edit]

These are all technically parser functions, but for all of these parser subroutines, the return value (the text displayed in the article) is always an empty string. The purpose of these subroutines is not to directly display content in the article, but rather to do various types of behind-the-scenes processing.

Word Example Explanation
{{#define:}} {{#define:arg|10}}
{{#local:}} {{#local:arg|10}}
{{#preview:}} {{#preview:arg|10}}
{{#unset:}} {{#unset:arg|foo|bar}}
{{#inherit:}} {{#inherit:arg|foo|bar}}
{{#return:}} {{#return:arg|foo|bar}}
{{#save:}} {{#save:arg|foo|bar}}
{{#load:}} {{#load:filename|arg|foo|bar}}
{{#inittrail:}} {{#inittrail:link1|link2}} [UespCustomCode] Initialize a bread crumb trail. The trail will start with the namespace's default trail (NS_TRAIL), then any additional arguments provided to #inittrail will be added as additional links in the trail. If the arguments are not already links, they will automatically be converted into links (e.g., "link1" would be changed into [[{{NS_FULL}}link1|link1]]. #inittrail overrides any earlier bread crumb trail functions on the page.
{{#settrail:}} {{#settrail:link1|link2}} [UespCustomCode] Set a bread crumb trail to the provided links. Unlike #settrail, the trail will not use the default NS_TRAIL, but will only be constructed out of the arguments provided to #settrail. As with #inittrail, arguments are automatically converted into links. #settrail overrides any earlier bread crumb trail functions on the page.
{{#addtotrail:}} {{#addtotrail:link1|link2}} [UespCustomCode] Append additional links to an existing bread crumb trail; unlike #settrail and #inittrail this does not erase any earlier bread crumb trail functions. Arguments are automatically converted into links.

Tag Functions[edit]

Word Example Explanation
<cleanspace>
...</cleanspace>
<cleanspace>
{{{do some stuff}}}
{{{do more stuff}}}
</cleanspace>
Cleans the leading & trailing whitespace as well as line breaks when used in templates (see Tag Functions)
<cleantable>
...</cleantable>
<cleantable>
{| class=wikitable
! Header1 !! Header2
|-
! Label1
| {{{possibly blank value|}}}
|-
! Label2
| {{{another possible blank|}}}
|}
</cleantable>
Removes rows from a table if the non-header cells contain only empty strings. Rows with only headers in them are never removed, only rows which have one or more non-header cells, all of which are blank.

Here is what the code to the left would look like if the first variable was blank and the second was equal to "abc":

Header1 Header2
Label2 abc
<displaycode>
...</displaycode>
<catpagetemplate>
...</catpagetemplate>