Help:Magic Words
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 MetaTemplate and Riven. 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) Skyrim Mod:Winterfrost/Through Fire And Ice |
Explanation |
---|---|---|
{{LABELNAME}} {{LABELNAME:arg}} (Riven) |
An Unexpected Voyage Through Fire And Ice |
This variable is the same as {{SUBPAGENAME}}, but any disambiguation-style parentheses are removed (similar to the pipe trick). Specifically, any words contained in parentheses at the end of the page name are removed, along with any whitespace. It is equivalent to {{#label:{{SUBPAGENAME}}}}. Like {{SUBPAGENAME}}, if an argument is provided that doesn't represent a valid page name (e.g., General:{Illegal} (example) ), nothing will be returned. |
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 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 NSInfo. In all cases:
- The definitions of the namespaces are provided by MediaWiki:nsinfo-namespacelist (which can be updated by admins and those patrollers who have interface editing permissions). The definition list can include both true namespaces and mods which contain articles that are subpages of the mod's main page (e.g., Skyrim Mod:Winterfrost).
- The variables are designed so that mods in the namespace list can be treated as if they were true namespaces, in particular within templates. These are often referred to interchangeably as mod namespaces, pseudo-namespaces, or just pseudo-spaces.
- There are three possible ways that these magic words can identify the requested namespace:
- 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:arg}}) or the ID of the namespace ({{NS_ID:arg}}). This option overrides any other options.
- If the magic word is called with an empty argument (e.g., {{NS_BASE:}}), then the code checks to see whether the template variables
ns_base
orns_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. - 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 WF |
Explanation |
---|---|---|
{{NS_BASE}} {{NS_BASE:arg}} |
Shivering Skyrim Mod:Winterfrost |
Returns the basic name of the subject namespace
|
{{MOD_NAME}} {{MOD_NAME:arg}} |
Winterfrost |
The name of the mod
|
{{NS_FULL}} {{NS_FULL:arg}} |
Shivering: Skyrim Mod:Winterfrost/ |
Returns the name of the namespace, including whatever punctuation is necessary before appending an article name.
|
{{NS_ID}} {{NS_ID:arg}} |
SI WF |
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 arguments to the namespace variables. (Note that this may not apply to other uses, such as in template parameter names.)
|
{{NS_PARENT}} {{NS_PARENT:arg}} |
Oblivion Skyrim |
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.
|
{{NS_NAME}} {{NS_NAME:arg}} |
Shivering Isles Winterfrost |
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 Skyrim Mod:Winterfrost |
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 Skyrim Mod-Winterfrost |
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 Mod / Skyrim: Skyrim Mod: Verified Creations: Winterfrost |
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 |
[Riven] Removes anything in parentheses at the end of the text, and also removes any whitespace preceding the parentheses, but only for one set of parentheses. This is the same way that the page name would by default appear in a link label. Unlike {{LABELNAME:arg}}, this function can be used for any arbitrary text, not just page names. |
{{#sortable:text}} | {{#sortable:A Pagename}}=Pagename, A {{#sortable:Another Pagename}}=Another Pagename |
[Riven] 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 page name. |
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}} | [MetaTemplate] Sets an undefined variable to the given value, thereafter acting as though that value had been passed in the template call. |
{{#local:}} | {{#local:arg|10}} | [MetaTemplate] Sets a variable to the given value, regardless of whether it was previously defined. This can be used to set local variables or to modify variables passed in the template call. |
{{#preview:}} | {{#preview:arg|10}} | [MetaTemplate] Sets an undefined variable to the given value, but only when Show Preview is used on the template page; it does not affect the functioning of the template in regular use. Note that modern versions of MediaWiki implement a similar feature by calling the edited version of the template during Show Preview rather than the saved version (i.e., in documentation examples), but both are useful in template design. |
{{#unset:}} | {{#unset:arg|foo|bar}} | [MetaTemplate] Clears the value of a variable as though it had never been set. |
{{#inherit:}} | {{#inherit:arg|foo|bar}} | [MetaTemplate] Defines one or more variables using that same variable's value in the calling page or template, climbing up the call stack if the variable is not found in the immediate caller. This will not override any values already defined. |
{{#return:}} | {{#return:arg|foo|bar}} | [MetaTemplate] Sets one or more variable values in the template's caller rather than the template itself, effectively returning a value by name. Note that unlike most programming languages, this does not force the template to return immediately; it merely sets the value in the calling template. This will override any values already defined. |
{{#save:}} | {{#save:arg|foo|bar}} | [MetaTemplate] Saves one or more variables to an internal database to allow those variables to be loaded and used in another template. |
{{#load:}} | {{#load:filename|arg|foo|bar}} | [MetaTemplate] Loads one or more variables from the internal database mentioned in #save. This will not override any values already defined. |
{{#inittrail:}} | {{#inittrail:link1|link2}} | [UespBreadCrumb] 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}} | [UespBreadCrumb] Set a bread crumb trail to the provided links. Unlike #inittrail, 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}} | [UespBreadCrumb] 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":
|
||||
<catpagetemplate> ...</catpagetemplate> |
<catpagetemplate> {{{{#define:catlabel|{{CORENAME:{{PAGENAME0}}}}}} </catpagetemplate> |
This would set the title for each entry in the category to just the page name, excluding the namespace or pseudo-namespace. Note that without a corresponding {{#define:catgroup}}, the example would present a straight category list with no group headers. |