Help:Magic Words
To meet our site's higher standard of quality, this article or section may require cleanup. The user who placed this here had the following concern: Needs to be checked to see which magic words actually apply here. To leave a message about the cleanup for this article, please add it to this article's talk page. |
This is a summary of magic words that are unique to UESP and Starfield Wiki. 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 Starfield Wiki 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 |
{{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. Note: there should no longer be any reason to use |
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 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 are often referred to interchangeably as mod namespaces, pseudo-namespaces, or just pseudo-spaces.
- 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:
- 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.
- If the magic word is called without an argument, 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 TR3 |
Explanation |
---|---|---|
{{NS_BASE}} {{NS_BASE:arg}} |
Shivering Tes3Mod:Tamriel Rebuilt |
Returns the basic name of the subject namespace
|
{{MOD_NAME}} {{MOD_NAME:arg}} |
Tamriel Rebuilt |
The name of the mod
|
{{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.
|
{{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 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 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.
|
{{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 Morrowind Mod: 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}} | [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}} | [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 #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}} | [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":
| ||||
<displaycode> ...</displaycode> |
<displaycode><span style="display:none">{{{1|}}}</span></displaycode> |
If used on Template:Hide, the code to the left would cause the template page to display the code of the template, much as if you'd used <nowiki> tags around the entire template. Unlike <nowiki>, however, this will not affect the template's function, only the display on its own page. Note that proper documentation is generally preferable. | ||||
<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. |