Help:Magic Words: Difference between revisions

From The Urban Dead Wiki
Jump to navigationJump to search
(→‎Page names, locations, and URLs: -Wikipedia link to ISO 8601)
 
(5 intermediate revisions by 5 users not shown)
Line 1: Line 1:
This is an organised index of all Magic words that are known to work on this wiki. "XYZ" indicates user input, which is used in the example.  
'''Magic words''' are strings of text that the wiki associates with a return value or function, such as time, site details, or page names.


== Table of contents ==
There are three general types of magic words:
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" width="75%"
*'''[[#Behaviour switches|Behavior switches]]''': these are uppercase words surrounded by double underscores, ''e.g.'' '''__FOO__'''
! Word !! Explanation
*'''[[#Variables|Variables]]''': these are uppercase words surrounded by double braces, ''e.g.'' '''<tt><nowiki>{{FOO}}</nowiki></tt>'''. As such, they look a lot like [[Help:Templates|templates]].
*'''[[#Parser functions|Parser functions]]''': these take parameters and are either of the form '''<tt><nowiki>{{foo:...}}</nowiki></tt>''' or '''<tt><nowiki>{{#foo:...}}</nowiki></tt>'''.
 
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.
 
==Behaviour switches==
A behaviour switch controls the layout or behaviour of the page and can often be used to specify desired omissions and inclusions in the content.
 
{| class="wikitable"
! Word
! Description
|-
| colspan="2"| '''Table of contents'''
|-
|-
| <nowiki>__NOTOC__</nowiki>
| <nowiki>__NOTOC__</nowiki>
| Hides the Table of Contents on the current page.
| Hides the table of contents (TOC).
|-
|-
|<nowiki>__FORCETOC__</nowiki>
|<nowiki>__FORCETOC__</nowiki>
| Forces the table of contents to appear.
| Forces the table of content to appear at its normal position (above the first header).
|-
|-
| <nowiki>__TOC__</nowiki>
| <nowiki>__TOC__</nowiki>
| Places a Table of Contents here. Also forces it to appear.
| Places a table of contents at the word's current position (overriding <nowiki>__NOTOC__</nowiki>). If this is used multiple times, the table of contents will appear at the first word's position.
|}<br clear="left" />
|-
| colspan="2"| '''Editing'''
|-
| <nowiki>__NOEDITSECTION__</nowiki>
| Hides the section edit links beside headings.
|-
| <nowiki>__NEWSECTIONLINK__</nowiki>
| Adds a link ("+") beside the "edit" tab for adding a new section on a non-talk page.
|-
| colspan="2"| '''Categories'''
|-
| <nowiki>__NOGALLERY__</nowiki>
| Used on a category page, replaces thumbnails in the category view with normal links.
|}
 
==Variables==
Variables return information about the current page, wiki, or date. Their syntax is similar to [[Help:Templates|templates]].


The Table of contents can also be forced onto a floating table on the right hand of the screen with the code below:
===Date & time===
The following variables return the current date and time according to the user's timezone [[Special:Preferences|preferences]], defaulting to the UTC timezone.


<pre>
Due to MediaWiki and browser caching, these variables frequently show when the page was ''cached'' rather than the current time.
  {| align="right"
  | __TOC__
  |}
</pre>


== More magic ==
{| class="wikitable"
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" width="75%"
! Variable
! Word !! Explanation
! Output
! Description
|-
| colspan="3"| '''Year'''
|-
| <tt><nowiki>{{CURRENTYEAR}}</nowiki></tt>
| {{CURRENTYEAR}}
| Year
|-
| colspan="3"| '''Month'''
|-
|-
| <nowiki>__NOEDITSECTION__</nowiki>
| <tt><nowiki>{{CURRENTMONTH}}</nowiki></tt>
| Hides the edit links beside headings.
| {{CURRENTMONTH}}
| Month (zero-padded number)
|-
| <tt><nowiki>{{CURRENTMONTHNAME}}</nowiki></tt>
| {{CURRENTMONTHNAME}}
| Month (name)
|-
| <tt><nowiki>{{CURRENTMONTHNAMEGEN}}</nowiki></tt>
| {{CURRENTMONTHNAMEGEN}}
| Month (genitive form)
|-
| <tt><nowiki>{{CURRENTMONTHABBREV}}</nowiki></tt>
| {{CURRENTMONTHABBREV}}
| Month (abbreviation)
|-
| colspan="3"| '''Day'''
|-
| <tt><nowiki>{{CURRENTDAY}}</nowiki></tt>
| {{CURRENTDAY}}
| Day of the month (unpadded number)
|-
| <tt><nowiki>{{CURRENTDAY2}}</nowiki></tt>
| {{CURRENTDAY2}}
| Day of the month (zero-padded number)
|-
| <tt><nowiki>{{CURRENTDOW}}</nowiki></tt>
| {{CURRENTDOW}}
| Day of the week (Sunday = 0 thru Saturday=6)
|-
| <tt><nowiki>{{CURRENTDAYNAME}}</nowiki></tt>
| {{CURRENTDAYNAME}}
| Day of the week (name)
|-
| colspan="3"| '''Time'''
|-
| <tt><nowiki>{{CURRENTTIME}}</nowiki></tt>
| {{CURRENTTIME}}
| Time (24-hour HH:mm format)
|-
| <tt><nowiki>{{CURRENTHOUR}}</nowiki></tt>
| {{CURRENTHOUR}}
| Hour (24-hour zero-padded number)
|-
| colspan="3"| '''Other'''
|-
|-
| <nowiki>__NOTITLECONVERT__</nowiki><br /><nowiki>__NOTC__</nowiki>
| <tt><nowiki>{{CURRENTWEEK}}</nowiki></tt>
| Like <nowiki>__NOCC__</nowiki> but affecting article title only.
| {{CURRENTWEEK}}
| Week (number)
|-
|-
| <nowiki>__END__</nowiki>
| <tt><nowiki>{{CURRENTTIMESTAMP}}</nowiki></tt>
| Allows for trailing whitespace to be included in the page save.
| {{CURRENTTIMESTAMP}}
|}<br clear="left" />
| YYYYMMDDHHmmss timestamp
|}


== Template modifiers ==
The following variables do the same as the above, but using the server's time (either UTC or BST (UTC+1) depending on daylight savings)
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" width="75%"
* <tt><nowiki>{{LOCALYEAR}}</nowiki></tt>
! Word !! Usage !! Explanation
* <tt><nowiki>{{LOCALMONTH}}</nowiki></tt>
* <tt><nowiki>{{LOCALMONTHNAME}}</nowiki></tt>
* <tt><nowiki>{{LOCALMONTHNAMEGEN}}</nowiki></tt>
* <tt><nowiki>{{LOCALMONTHABBREV}}</nowiki></tt>
* <tt><nowiki>{{LOCALDAY}}</nowiki></tt>
* <tt><nowiki>{{LOCALDAY2}}</nowiki></tt>
* <tt><nowiki>{{LOCALDOW}}</nowiki></tt>
* <tt><nowiki>{{LOCALDAYNAME}}</nowiki></tt>
* <tt><nowiki>{{LOCALTIME}}</nowiki></tt>
* <tt><nowiki>{{LOCALHOUR}}</nowiki></tt>
* <tt><nowiki>{{LOCALWEEK}}</nowiki></tt>
* <tt><nowiki>{{LOCALTIMESTAMP}}</nowiki></tt>
 
===Technical metadata===
Revision variables return data about the '''latest edit to the current page''', even if viewing an older version of the page.
{| class="wikitable"
|-
|-
| <nowiki>{{subst:}}</nowiki>
! Variable
| <nowiki>{{subst:XYZ}}</nowiki>
! Output
| Substitutes the template call with the ''content'' of the template.
! Description
|-
|-
| <nowiki>{{msg:}}</nowiki>
| colspan="3"| '''Site'''
| <nowiki>{{msg:XYZ}}</nowiki>
| If a template clashes with a magic word, use of the msg: modifier will use the template instead of the magic word. Otherwise, the magic word is used.
|-
|-
| <nowiki>{{msgnw:}}</nowiki>
| <tt><nowiki>{{SITENAME}}</nowiki></tt>
| <nowiki>{{msgnw:XYZ}}</nowiki>
| {{SITENAME}}
| The template message is pasted as unevaluated &lt;nowiki&gt; text.
| The wiki's site name
|-
|-
| <nowiki>{{INT:}}</nowiki>
| <tt><nowiki>{{SERVER}}</nowiki></tt>
| <nowiki>{{INT:XYZ}}</nowiki>
| {{SERVER}}
| If a template clashes with a MediaWiki:message, use of the INT: modifier will use the message instead of the template. Otherwise, the template is used.
| domain URL
|-
| <tt><nowiki>{{SERVERNAME}}</nowiki></tt>
| {{SERVERNAME}}
| domain name
|-
| <tt><nowiki>{{CURRENTVERSION}}</nowiki></tt>
| {{CURRENTVERSION}}
| The wiki's MediaWiki version.
|-
| colspan="3"| '''Latest revision to current page'''
|-
| <tt><nowiki>{{REVISIONID}}</nowiki></tt>
| {{REVISIONID}}
| Unique revision ID
|-
| <tt><nowiki>{{REVISIONDAY}}</nowiki></tt>
| {{REVISIONDAY}}
| Day edit was made (unpadded number)
|-
| <tt><nowiki>{{REVISIONDAY2}}</nowiki></tt>
| {{REVISIONDAY2}}
| Day edit was made (zero-padded number)
|-
| <tt><nowiki>{{REVISIONMONTH}}</nowiki></tt>
| {{REVISIONMONTH}}
| Month edit was made (unpadded number)
|-
| <tt><nowiki>{{REVISIONYEAR}}</nowiki></tt>
| {{REVISIONYEAR}}
| Year edit was made
|-
| <tt><nowiki>{{REVISIONTIMESTAMP}}</nowiki></tt>
| {{REVISIONTIMESTAMP}}
| Timestamp as of time of edit
|}
|}


== Time ==
===Statistics===
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
Numbers returned by these variables normally contain separators (commas or spaces, depending on the local language), but can return raw numbers with the ":R" flag (for example, <code><tt><nowiki>{{NUMBEROFPAGES}}</nowiki></tt></code> → {{NUMBEROFPAGES}} and <code><tt><nowiki>{{NUMBEROFPAGES:R}}</nowiki></tt></code> → {{NUMBEROFPAGES:R}}).
! Word !! Example !! Explanation
 
{| class="wikitable"
! Variable
! Output
! Description
|-
| colspan="3"| '''Entire wiki'''
|-
|-
| <nowiki>{{CURRENTDAY}}</nowiki>
| <tt><nowiki>{{NUMBEROFPAGES}}</nowiki></tt>
| <code>{{CURRENTDAY}}</code>
| {{NUMBEROFPAGES}}
| Displays the current day in numeric form.
| Number of wiki pages.
|-
|-
| <nowiki>{{CURRENTDAYNAME}}</nowiki>
| <tt><nowiki>{{NUMBEROFARTICLES}}</nowiki></tt>
| <code>{{CURRENTDAYNAME}}</code>
| {{NUMBEROFARTICLES}}
| Displays the current day in named form.
| Number of pages in main namespace without Main Page.
|-
|-
| <nowiki>{{CURRENTDOW}}</nowiki>
| <tt><nowiki>{{NUMBEROFFILES}}</nowiki></tt>
| <code>{{CURRENTDOW}}</code>
| {{NUMBEROFFILES}}
| Displays the current day as a number of the week (0=Sunday, 1=Monday...).
| Number of uploaded files.
|-
|-
| <nowiki>{{CURRENTMONTH}}</nowiki>
| <tt><nowiki>{{NUMBEROFUSERS}}</nowiki></tt>
| <code>{{CURRENTMONTH}}</code>
| {{NUMBEROFUSERS}}
| Displays the current month in numeric form.
| Number of registered users.
|-
|-
| <nowiki>{{CURRENTMONTHABBREV}}</nowiki>
| <tt><nowiki>{{NUMBEROFADMINS}}</nowiki></tt>
| <code>{{CURRENTMONTHABBREV}}</code>
| {{NUMBEROFADMINS}}
| Displays the abbreviation of the current month.
| Number of sysops.
|-
|-
| <nowiki>{{CURRENTMONTHNAME}}</nowiki>
| <tt><nowiki>{{PAGESINCATEGORY:Guides}}</nowiki></tt>
| <code>{{CURRENTMONTHNAME}}</code>
| {{PAGESINCATEGORY:Guides}}
| Displays the current month in named form.
| Number of pages in the specified category.
|}
 
====Page names====
{| class="wikitable"
! Variable
! Output
! Description
|-
|-
| <nowiki>{{CURRENTMONTHNAMEGEN}}</nowiki>
| <tt><nowiki>{{FULLPAGENAME}}</nowiki></tt>
| <code>{{CURRENTMONTHNAMEGEN}}</code>
| {{FULLPAGENAME}}
| Displays the name of the current month in genitive form. Wikis that don't support this will default to <nowiki>{{CURRENTMONTHNAME}}</nowiki>.
| Namespace and page title. ("Help:Title/Page/Subpage" on "Help:Title/Page/Subpage").
|-
|-
| <nowiki>{{CURRENTTIME}}</nowiki>
| <tt><nowiki>{{PAGENAME}}</nowiki></tt>
| <code>{{CURRENTTIME}}</code>
| {{PAGENAME}}
| Displays the current time of day (hours:minutes).
| Page title excluding namespace. ("Title/Page/Subpage" on "Help:Title/Page/Subpage").
|-
|-
| <nowiki>{{CURRENTWEEK}}</nowiki>
| <tt><nowiki>{{BASEPAGENAME}}</nowiki></tt>
| <code>{{CURRENTWEEK}}</code>
| {{BASEPAGENAME}}
| Displays the number of the current week (1-52).
| Page title excluding the current subpage and namespace ("Title/Page" on "Help:Title/Page/Subpage").
|-
|-
| <nowiki>{{CURRENTYEAR}}</nowiki>
| <tt><nowiki>{{SUBPAGENAME}}</nowiki></tt>
| <code>{{CURRENTYEAR}}</code>
| {{SUBPAGENAME}}
| Returns the current year.
| The subpage title ("Subpage" on "Help:Title/Page/Subpage").
|}<br clear="all" />
|-
| <tt><nowiki>{{SUBJECTPAGENAME}}</nowiki></tt>
| {{SUBJECTPAGENAME}}
| The namespace and title of the associated content page.
|-
| <tt><nowiki>{{TALKPAGENAME}}</nowiki></tt>
| {{TALKPAGENAME}}
| The namespace and title of the associated talk page.
|}
 
The <tt><nowiki>{{BASEPAGENAME}}</nowiki></tt> and <tt><nowiki>{{SUBPAGENAME}}</nowiki></tt> magic words only work in namespaces that have subpages enabled.
 
The following are URL-encoded equivalents:
* <tt><nowiki>{{FULLPAGENAMEE}}</nowiki></tt>
* <tt><nowiki>{{PAGENAMEE}}</nowiki></tt>
* <tt><nowiki>{{BASEPAGENAMEE}}</nowiki></tt>
* <tt><nowiki>{{SUBPAGENAMEE}}</nowiki></tt>
* <tt><nowiki>{{SUBJECTPAGENAMEE}}</nowiki></tt>
* <tt><nowiki>{{TALKPAGENAMEE}}</nowiki></tt>


== Page names, locations, and URLs ==
====Namespaces====
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
{| class="wikitable"
! Word !! Example !! Explanation
! Variable
! Output
! Description
|-
|-
| <nowiki>{{PAGENAME}}</nowiki>
| <tt><nowiki>{{NAMESPACE}}</nowiki></tt>
| <code>{{PAGENAME}}</code>
| {{NAMESPACE}}
| Returns the name of the current page, including all levels (Title/Subtitle/Sub-subtitle).
| Namespace (name)
|-
|-
| <nowiki>{{PAGENAMEE}}</nowiki>
| <tt><nowiki>{{SUBJECTSPACE}}</nowiki></tt><br /><tt><nowiki>{{ARTICLESPACE}}</nowiki></tt>
| <code>{{PAGENAMEE}}</code>
| {{SUBJECTSPACE}}<br />{{ARTICLESPACE}}
| More URL-friendly percent encoded special characters (rarely necessary).
| Name of the associated content namespace
|-
|-
| <nowiki>{{SUBPAGENAME}}</nowiki><br /><nowiki>{{SUBPAGENAMEE}}</nowiki>
| <tt><nowiki>{{TALKSPACE}}</nowiki></tt>
| <code>{{SUBPAGENAME}}<br />{{SUBPAGENAMEE}}</code>
| {{TALKSPACE}}
| Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages.
| Name of the associated talk namespace
|}
 
The following are URL-encoded equivalents:
* <tt><nowiki>{{NAMESPACEE}}</nowiki></tt>
* <tt><nowiki>{{SUBJECTSPACEE}}</nowiki></tt>
* <tt><nowiki>{{TALKSPACEE}}</nowiki></tt>
 
==Parser functions==
 
Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is usually prefixed with a hash to distinguish them from possible templates)
 
This page only describes parser functions that are integral to the MediaWiki software. This wiki does not have the Parser functions extension.
 
===URL data===
{| class="wikitable"
! Parser function
! Input → Output
! Description
|-
|-
| <nowiki>{{BASEPAGENAME}}</nowiki><br ><nowiki>{{BASEPAGENAMEE}}</nowiki>
| <tt><nowiki>{{localurl:</nowiki>''page name''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{localurl:</nowiki>''page name''<nowiki>|</nowiki>''query string''<nowiki>}}</nowiki></tt>
| <code>{{BASEPAGENAME}}<br />{{BASEPAGENAMEE}}</code>
| <nowiki>{{localurl:Help:Magic Words}}</nowiki> {{localurl:Help:Magic Words}}<br /><nowiki>{{localurl:Help:Magic Words|printable=yes}}</nowiki> → {{localurl:Help:Magic Words|printable=yes}}
| The basename of a subpage ("Title/Other" on "Title/Other/Subtitle").
| The relative path to the title.  
|-
|-
| <nowiki>{{NAMESPACE}}</nowiki>
| <tt><nowiki>{{fullurl:</nowiki>''page name''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{fullurl:</nowiki>''page name''<nowiki>|</nowiki>''query_string''<nowiki>}}</nowiki></tt>
| <code>{{NAMESPACE}}</code>
| <nowiki>{{fullurl:Help:Magic Words}}</nowiki> → {{fullurl:Help:Magic Words}}<br />
| Returns the name of the namespace the current page resides in.
<nowiki>{{fullurl:Help:Magic Words|action=edit}}</nowiki> → {{fullurl:Help:Magic Words|action=edit}}
| The absolute path to the title.
|-
|-
| <nowiki>{{FULLPAGENAME}}</nowiki><br ><nowiki>{{FULLPAGENAMEE}}</nowiki>
| <tt><nowiki>{{urlencode:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{FULLPAGENAME}}<br />{{FULLPAGENAMEE}}</code>
| <nowiki>{{urlencode:x y z}}</nowiki> {{urlencode:x y z}}
| Shorthands for NAMESPACE+PAGENAME
| The input encoded for use in URLs.
|-
|-
| <nowiki>{{TALKSPACE}}</nowiki><br ><nowiki>{{TALKSPACEE}}</nowiki>
| <tt><nowiki>{{anchorencode:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{TALKSPACE}}<br />{{TALKSPACEE}}</code>
| <nowiki>{{anchorencode:x y z}}</nowiki> → {{anchorencode:x y z}}
| Name of next odd namespace (e.g. 4 =&gt; 5) 
| The input encoded for use in URL section anchors (after the '#' symbol in a URL).
|}
 
===Namespaces===
<code><tt><nowiki>{{ns:}}</nowiki></tt></code> returns the localized name for the namespace with that index.
{| class="wikitable"
! colspan="2" width="50%" | Content namespaces
! rowspan="11" |
! colspan="2" width=%50%" | Talk namespaces
|-
|-
| <nowiki>{{SUBJECTSPACE}}</nowiki><br ><nowiki>{{SUBJECTSPACEE}}</nowiki>
! Usage
| <code>{{SUBJECTSPACE}}<br />{{SUBJECTSPACEE}}</code>
! Output
| Name of last even namespace (e.g. 5 =&gt; 4)
! Usage
! Output
|-
|-
| <nowiki>{{ARTICLESPACE}}</nowiki><br ><nowiki>{{ARTICLESPACEE}}</nowiki>
| <tt><nowiki>{{ns:-2}}</nowiki></tt> or <tt><nowiki>{{ns:Media}}</nowiki></tt>
| <code>{{ARTICLESPACE}}<br />{{ARTICLESPACEE}}</code>
| {{ns:-2}}
| An alias for SUBJECTSPACE(E)
| <tt><nowiki>{{ns:-1}}</nowiki></tt> or <tt><nowiki>{{ns:Special}}</nowiki></tt>
| {{ns:-1}}
|-
|-
| <nowiki>{{TALKPAGENAME}}</nowiki><br ><nowiki>{{TALKPAGENAMEE}}</nowiki>
| <tt><nowiki>{{ns:0}}</nowiki></tt>
| <code>{{TALKPAGENAME}}<br />{{TALKPAGENAMEE}}</code>
| {{ns:0}}
| FULLPAGENAME in its TALKSPACE
| <tt><nowiki>{{ns:1}}</nowiki></tt> or <tt><nowiki>{{ns:Talk}}</nowiki></tt>
| {{ns:1}}
|-
|-
| <nowiki>{{SUBJECTPAGENAME}}</nowiki><br ><nowiki>{{SUBJECTPAGENAMEE}}</nowiki>
| <tt><nowiki>{{ns:2}}</nowiki></tt> or <tt><nowiki>{{ns:User}}</nowiki></tt>
| <code>{{SUBJECTPAGENAME}}<br />{{SUBJECTPAGENAMEE}}</code>
| {{ns:2}}
| FULLPAGENAME in its SUBJECTSPACE
| <tt><nowiki>{{ns:3}}</nowiki></tt> or <tt><nowiki>{{ns:User talk}}</nowiki></tt>
| {{ns:3}}
|-
|-
| <nowiki>{{ARTICLEPAGENAME}}</nowiki><br ><nowiki>{{ARTICLEPAGENAMEE}}</nowiki>
| <tt><nowiki>{{ns:4}}</nowiki></tt> or <tt><nowiki>{{ns:Project}}</nowiki></tt>
| <code>{{ARTICLEPAGENAME}}<br />{{ARTICLEPAGENAMEE}}</code>
| {{ns:4}}
| An alias for SUBJECTPAGENAME(E)
| <tt><nowiki>{{ns:5}}</nowiki></tt> or <tt><nowiki>{{ns:Project talk}}</nowiki></tt>
| {{ns:5}}
|-
|-
| <nowiki>{{REVISIONID}}</nowiki>
| <tt><nowiki>{{ns:6}}</nowiki></tt> or <tt><nowiki>{{ns:File}}</nowiki></tt> or <tt><nowiki>{{ns:Image}}</nowiki></tt>
| <code>{{REVISIONID}}</code>
| {{ns:6}}
| Gives you the unique identifying number of the article or diff database.
| <tt><nowiki>{{ns:7}}</nowiki></tt> or <tt><nowiki>{{ns:File talk}}</nowiki></tt> or <tt><nowiki>{{ns:Image talk}}</nowiki></tt>
| {{ns:7}}
|-
|-
| <nowiki>{{REVISIONDAY}}</nowiki>
| <tt><nowiki>{{ns:8}}</nowiki></tt> or <tt><nowiki>{{ns:MediaWiki}}</nowiki></tt>
| <code>{{REVISIONDAY}}</code>
| {{ns:8}}
| The day on which the page was last modified.
| <tt><nowiki>{{ns:9}}</nowiki></tt> or <tt><nowiki>{{ns:MediaWiki talk}}</nowiki></tt>
| {{ns:9}}
|-
|-
| <nowiki>{{REVISIONDAY2}}</nowiki>
| <tt><nowiki>{{ns:10}}</nowiki></tt> or <tt><nowiki>{{ns:Template}}</nowiki></tt>
| <code>{{REVISIONDAY2}}</code>
| {{ns:10}}
| The day on which the page was last modified, but with a leading zero (01 .. 31).
| <tt><nowiki>{{ns:11}}</nowiki></tt> or <tt><nowiki>{{ns:Template talk}}</nowiki></tt>
| {{ns:11}}
|-
|-
| <nowiki>{{REVISIONMONTH}}</nowiki>
| <tt><nowiki>{{ns:12}}</nowiki></tt> or <tt><nowiki>{{ns:Help}}</nowiki></tt>
| <code>{{REVISIONMONTH}}</code>
| {{ns:12}}
| The month in which the page was last modified.
| <tt><nowiki>{{ns:13}}</nowiki></tt> or <tt><nowiki>{{ns:Help talk}}</nowiki></tt>
| {{ns:13}}
|-
|-
| <nowiki>{{REVISIONYEAR}}</nowiki>
| <tt><nowiki>{{ns:14}}</nowiki></tt> or <tt><nowiki>{{ns:Category}}</nowiki></tt>
| <code>{{REVISIONYEAR}}</code>
| {{ns:14}}
| The year in which the page was last modified.
| <tt><nowiki>{{ns:15}}</nowiki></tt> or <tt><nowiki>{{ns:Category talk}}</nowiki></tt>
| {{ns:15}}
|}
 
===Formatting===
{| class="wikitable"
! Usage
! Input → Output
! Description
|-
|-
| <nowiki>{{REVISIONTIMESTAMP}}</nowiki>
| <tt><nowiki>{{lc:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{REVISIONTIMESTAMP}}</code>
| <tt><nowiki>{{lc:TEXT TRANSFORM}}</nowiki></tt> → {{lc:TEXT TRANSFORM}}
| [[wikipedia:ISO 8601|ISO 8601]] time stamp, indicating when the page was last modified.
| The lowercase input.
|-
|-
| <nowiki>{{SITENAME}}</nowiki>
| <tt><nowiki>{{lcfirst:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{SITENAME}}</code>
| <tt><nowiki>{{lcfirst:TEXT TRANSFORM}}</nowiki></tt> → {{lcfirst:TEXT TRANSFORM}}
| Returns the name of the wiki (set in <tt>LocalSettings.php</tt>).
| The input with the <u>very first</u> character lowercase.
|-
|-
| <nowiki>{{NS:}}</nowiki>
| <tt><nowiki>{{uc:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <nowiki>{{NS:4}}</nowiki> = <code>{{NS:4}}</code><br /><nowiki>{{NS:PROJECT}}</nowiki> = <code>{{NS:PROJECT}}</code>
| <tt><nowiki>{{uc:text transform}}</nowiki></tt> {{uc:text transform}}
| Returns the name of a given [[UDWiki:Namespaces|namespace number]].
| The uppercase input.
|-
|-
| <nowiki>{{LOCALURL:x y}}</nowiki><br /><nowiki>{{LOCALURLE:%}}</nowiki>
| <tt><nowiki>{{ucfirst:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{localurl:x y}}<br />{{localurle:%}}</code>
| <tt><nowiki>{{ucfirst:text transform}}</nowiki></tt> {{ucfirst:text transform}}
| Returns the local URL of a given page. The page might not exist.
| The input with the <u>very first</u> character uppercase.
|-
|-
| <nowiki>{{SERVER}}</nowiki>
| <tt><nowiki>{{formatnum:</nowiki>''unformatted&nbsp;num''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{formatnum:</nowiki>''formatted&nbsp;num''<nowiki>|R}}</nowiki></tt>
| <small>{{SERVER}}</small>
| <tt><nowiki>{{formatnum:-987654321.654321}}</nowiki></tt> → {{formatnum:-987654321.654321}}
| Returns the domain and subdomain URL of the wiki.
| Formats a number.
|-
|-
| <nowiki>{{SCRIPTPATH}}</nowiki>
| <tt><nowiki>{{padleft:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{padleft:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></tt>
| <code>{{SCRIPTPATH}}</code>
| <tt><nowiki>{{padleft:xyz|5}}</nowiki></tt> {{padleft:xyz|5}}<br /> <tt><nowiki>{{padleft:xyz|5|_}}</nowiki></tt> → {{padleft:xyz|5|_}}
| Returns the value of $wgScriptPath in <tt>LocalSettings.php</tt>.
| Inserts a string of padding characters (character chosen in third parameter; default '0') of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. <nowiki>{{padleft:44|3|0}}</nowiki> produces {{padleft:44|3}}.
|-
|-
| <nowiki>{{SERVERNAME}}</nowiki>
| <tt><nowiki>{{padright:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{padright:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></tt>
| <code>{{SERVERNAME}}</code>
| <tt><nowiki>{{padright:xyz|5}}</nowiki></tt> → {{padright:xyz|5}}<br /> <tt><nowiki>{{padright:xyz|5|_}}</nowiki></tt> → {{padright:xyz|5|_}}
| Returns the value of $wgServerName in <tt>LocalSettings.php</tt>.
| Identical to padleft, but adds padding characters to the right side.
|-
| <tt><nowiki>{{plural:2|</nowiki>''is''<nowiki>|</nowiki>''are''<nowiki>}}</nowiki></tt>
| <tt><nowiki>{{plural:1|is|are}}</nowiki></tt> → {{plural:1|is|are}}<br /> <tt><nowiki>{{plural:2|is|are}}</nowiki></tt> → {{plural:2|is|are}}
| Outputs the correct given pluralization form (parameters except first) depending on the count (first parameter). Plural transformations are used for languages like Russian based on "count mod 10".
|}
|}


== Miscellaneous ==
===Miscellaneous===
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
{| class="wikitable plainlinks"
! Word
! Usage
! Usage
! Output
! Explanation
! Description
|-
|-
| <nowiki>{{NUMBEROFARTICLES}}</nowiki>
| <tt><nowiki>{{#language:</nowiki>''language code''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{#language:ar}}</nowiki></tt><br /><tt><nowiki>{{#language:th}}</nowiki></tt>
| <code>{{NUMBEROFARTICLES}}</code>
| {{#language:language code}}<br />{{#language:ar}}<br />{{#language:th}}
| A [[Help:Variable|variable]] which returns the total number of articles on the Wiki.
| The native name for the given language code, in accordance with ISO 639.
|-
|-
| <nowiki>{{NUMBEROFFILES}}</nowiki>
| <tt><nowiki>{{#special:</nowiki>''special page name''<nowiki>}}</nowiki><br /><nowiki>{{#special:userlogin}}</nowiki></tt>
| <code>{{NUMBEROFFILES}}</code>
| {{#special:special page name}}<br />{{#special:userlogin}}
| Returns the number of uploaded files (rows in the image table).
| The localized name for the given canonical Special: page.
|-
|}
| <nowiki>#redirect</nowiki>  
| <code>#REDIRECT&#160;[&#91;target&#93;]</code><br />at top of source page
| Creates a [[Help:Redirect|redirect]] to another page.
|}<br clear="all" />


{{Template:EditHelpMenu}}
{{EditHelpMenu}}
[[Category:Help]]

Latest revision as of 04:34, 19 November 2012

Magic words are strings of text that the wiki associates with a return value or function, such as time, site details, or page names.

There are three general types of magic words:

  • Behavior switches: these are uppercase words surrounded by double underscores, e.g. __FOO__
  • Variables: these are uppercase words surrounded by double braces, e.g. {{FOO}}. As such, they look a lot like templates.
  • Parser functions: these take parameters and are either of the form {{foo:...}} or {{#foo:...}}.

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.

Behaviour switches

A behaviour switch controls the layout or behaviour of the page and can often be used to specify desired omissions and inclusions in the content.

Word Description
Table of contents
__NOTOC__ Hides the table of contents (TOC).
__FORCETOC__ Forces the table of content to appear at its normal position (above the first header).
__TOC__ Places a table of contents at the word's current position (overriding __NOTOC__). If this is used multiple times, the table of contents will appear at the first word's position.
Editing
__NOEDITSECTION__ Hides the section edit links beside headings.
__NEWSECTIONLINK__ Adds a link ("+") beside the "edit" tab for adding a new section on a non-talk page.
Categories
__NOGALLERY__ Used on a category page, replaces thumbnails in the category view with normal links.

Variables

Variables return information about the current page, wiki, or date. Their syntax is similar to templates.

Date & time

The following variables return the current date and time according to the user's timezone preferences, defaulting to the UTC timezone.

Due to MediaWiki and browser caching, these variables frequently show when the page was cached rather than the current time.

Variable Output Description
Year
{{CURRENTYEAR}} 2025 Year
Month
{{CURRENTMONTH}} 03 Month (zero-padded number)
{{CURRENTMONTHNAME}} March Month (name)
{{CURRENTMONTHNAMEGEN}} March Month (genitive form)
{{CURRENTMONTHABBREV}} Mar Month (abbreviation)
Day
{{CURRENTDAY}} 4 Day of the month (unpadded number)
{{CURRENTDAY2}} 04 Day of the month (zero-padded number)
{{CURRENTDOW}} 2 Day of the week (Sunday = 0 thru Saturday=6)
{{CURRENTDAYNAME}} Tuesday Day of the week (name)
Time
{{CURRENTTIME}} 14:55 Time (24-hour HH:mm format)
{{CURRENTHOUR}} 14 Hour (24-hour zero-padded number)
Other
{{CURRENTWEEK}} 10 Week (number)
{{CURRENTTIMESTAMP}} 20250304145503 YYYYMMDDHHmmss timestamp

The following variables do the same as the above, but using the server's time (either UTC or BST (UTC+1) depending on daylight savings)

  • {{LOCALYEAR}}
  • {{LOCALMONTH}}
  • {{LOCALMONTHNAME}}
  • {{LOCALMONTHNAMEGEN}}
  • {{LOCALMONTHABBREV}}
  • {{LOCALDAY}}
  • {{LOCALDAY2}}
  • {{LOCALDOW}}
  • {{LOCALDAYNAME}}
  • {{LOCALTIME}}
  • {{LOCALHOUR}}
  • {{LOCALWEEK}}
  • {{LOCALTIMESTAMP}}

Technical metadata

Revision variables return data about the latest edit to the current page, even if viewing an older version of the page.

Variable Output Description
Site
{{SITENAME}} The Urban Dead Wiki The wiki's site name
{{SERVER}} //wiki.urbandead.com domain URL
{{SERVERNAME}} wiki.urbandead.com domain name
{{CURRENTVERSION}} 1.39.11 The wiki's MediaWiki version.
Latest revision to current page
{{REVISIONID}} 2041895 Unique revision ID
{{REVISIONDAY}} 19 Day edit was made (unpadded number)
{{REVISIONDAY2}} 19 Day edit was made (zero-padded number)
{{REVISIONMONTH}} 11 Month edit was made (unpadded number)
{{REVISIONYEAR}} 2012 Year edit was made
{{REVISIONTIMESTAMP}} 20121119043404 Timestamp as of time of edit

Statistics

Numbers returned by these variables normally contain separators (commas or spaces, depending on the local language), but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}} → 152,355 and {{NUMBEROFPAGES:R}} → 152355).

Variable Output Description
Entire wiki
{{NUMBEROFPAGES}} 152,355 Number of wiki pages.
{{NUMBEROFARTICLES}} 19,396 Number of pages in main namespace without Main Page.
{{NUMBEROFFILES}} 22,081 Number of uploaded files.
{{NUMBEROFUSERS}} 51,363 Number of registered users.
{{NUMBEROFADMINS}} 11 Number of sysops.
{{PAGESINCATEGORY:Guides}} 132 Number of pages in the specified category.

Page names

Variable Output Description
{{FULLPAGENAME}} Help:Magic Words Namespace and page title. ("Help:Title/Page/Subpage" on "Help:Title/Page/Subpage").
{{PAGENAME}} Magic Words Page title excluding namespace. ("Title/Page/Subpage" on "Help:Title/Page/Subpage").
{{BASEPAGENAME}} Magic Words Page title excluding the current subpage and namespace ("Title/Page" on "Help:Title/Page/Subpage").
{{SUBPAGENAME}} Magic Words The subpage title ("Subpage" on "Help:Title/Page/Subpage").
{{SUBJECTPAGENAME}} Help:Magic Words The namespace and title of the associated content page.
{{TALKPAGENAME}} Help talk:Magic Words The namespace and title of the associated talk page.

The {{BASEPAGENAME}} and {{SUBPAGENAME}} magic words only work in namespaces that have subpages enabled.

The following are URL-encoded equivalents:

  • {{FULLPAGENAMEE}}
  • {{PAGENAMEE}}
  • {{BASEPAGENAMEE}}
  • {{SUBPAGENAMEE}}
  • {{SUBJECTPAGENAMEE}}
  • {{TALKPAGENAMEE}}

Namespaces

Variable Output Description
{{NAMESPACE}} Help Namespace (name)
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Help
Help
Name of the associated content namespace
{{TALKSPACE}} Help talk Name of the associated talk namespace

The following are URL-encoded equivalents:

  • {{NAMESPACEE}}
  • {{SUBJECTSPACEE}}
  • {{TALKSPACEE}}

Parser functions

Parser functions are very similar to variables, but take one or more parameters (technically, any magic word that takes a parameter is a parser function), and the name is usually prefixed with a hash to distinguish them from possible templates)

This page only describes parser functions that are integral to the MediaWiki software. This wiki does not have the Parser functions extension.

URL data

Parser function Input → Output Description
{{localurl:page name}}
{{localurl:page name|query string}}
{{localurl:Help:Magic Words}} → /index.php/Help:Magic_Words
{{localurl:Help:Magic Words|printable=yes}} → /index.php?title=Help:Magic_Words&printable=yes
The relative path to the title.
{{fullurl:page name}}
{{fullurl:page name|query_string}}
{{fullurl:Help:Magic Words}} → //wiki.urbandead.com/index.php/Help:Magic_Words

{{fullurl:Help:Magic Words|action=edit}} → //wiki.urbandead.com/index.php?title=Help:Magic_Words&action=edit

The absolute path to the title.
{{urlencode:string}} {{urlencode:x y z}} → x+y+z The input encoded for use in URLs.
{{anchorencode:string}} {{anchorencode:x y z}} → x_y_z The input encoded for use in URL section anchors (after the '#' symbol in a URL).

Namespaces

{{ns:}} returns the localized name for the namespace with that index.

Content namespaces Talk namespaces
Usage Output Usage Output
{{ns:-2}} or {{ns:Media}} Media {{ns:-1}} or {{ns:Special}} Special
{{ns:0}} {{ns:1}} or {{ns:Talk}} Talk
{{ns:2}} or {{ns:User}} User {{ns:3}} or {{ns:User talk}} User talk
{{ns:4}} or {{ns:Project}} UDWiki {{ns:5}} or {{ns:Project talk}} UDWiki talk
{{ns:6}} or {{ns:File}} or {{ns:Image}} File {{ns:7}} or {{ns:File talk}} or {{ns:Image talk}} File talk
{{ns:8}} or {{ns:MediaWiki}} MediaWiki {{ns:9}} or {{ns:MediaWiki talk}} MediaWiki talk
{{ns:10}} or {{ns:Template}} Template {{ns:11}} or {{ns:Template talk}} Template talk
{{ns:12}} or {{ns:Help}} Help {{ns:13}} or {{ns:Help talk}} Help talk
{{ns:14}} or {{ns:Category}} Category {{ns:15}} or {{ns:Category talk}} Category talk

Formatting

Usage Input → Output Description
{{lc:string}} {{lc:TEXT TRANSFORM}} → text transform The lowercase input.
{{lcfirst:string}} {{lcfirst:TEXT TRANSFORM}} → tEXT TRANSFORM The input with the very first character lowercase.
{{uc:string}} {{uc:text transform}} → TEXT TRANSFORM The uppercase input.
{{ucfirst:string}} {{ucfirst:text transform}} → Text transform The input with the very first character uppercase.
{{formatnum:unformatted num}}
{{formatnum:formatted num|R}}
{{formatnum:-987654321.654321}} → −987,654,321.654321 Formats a number.
{{padleft:xyz|stringlength}}
{{padleft:xyz|strlen|char}}
{{padleft:xyz|5}} → 00xyz
{{padleft:xyz|5|_}} → __xyz
Inserts a string of padding characters (character chosen in third parameter; default '0') of a specified length (second parameter) next to a chosen base character or variable (first parameter). The final digits or characters in the base replace the final characters in the padding; i.e. {{padleft:44|3|0}} produces 044.
{{padright:xyz|stringlength}}
{{padright:xyz|strlen|char}}
{{padright:xyz|5}} → xyz00
{{padright:xyz|5|_}} → xyz__
Identical to padleft, but adds padding characters to the right side.
{{plural:2|is|are}} {{plural:1|is|are}} → is
{{plural:2|is|are}} → are
Outputs the correct given pluralization form (parameters except first) depending on the count (first parameter). Plural transformations are used for languages like Russian based on "count mod 10".

Miscellaneous

Editing Help
Basic Editing

Advanced Editing

Advanced Timesavers

Page Tricks

Communicating your Edits

Miscellaneous

Policies and Guidelines
Guidelines

Policy Documents