Help:Magic Words: Difference between revisions

From The Urban Dead Wiki
Jump to navigationJump to search
m (→‎Time: {{CURRENTHOUR}})
(Replacing page with a version of MediaWiki's with some of the nonworking stuff removed)
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%"
*'''[[#Behavior 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.
|}


The Table of contents can also be forced onto a floating table on the right hand of the screen with the code below:
==Variables==
Variables return information about the current page, wiki, or date. Their syntax is similar to [[Help:Templates|templates]].


<pre>
===Date & time===
  {| align="right"
The following variables return the current date and time according to the user's timezone [[Special:Preferences|preferences]], defaulting to the UTC timezone.
  | __TOC__
  |}
</pre>


== More magic ==
Due to MediaWiki and browser caching, these variables frequently show when the page was ''cached'' rather than the current time.
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;" width="75%"
 
! Word !! Explanation
{| class="wikitable"
! Variable
! Output
! Description
|-
| colspan="3"| '''Year'''
|-
| <tt><nowiki>{{CURRENTYEAR}}</nowiki></tt>
| {{CURRENTYEAR}}
| Year
|-
| colspan="3"| '''Month'''
|-
| <tt><nowiki>{{CURRENTMONTH}}</nowiki></tt>
| {{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)
|-
|-
| <nowiki>__NOEDITSECTION__</nowiki>
| <tt><nowiki>{{CURRENTDOW}}</nowiki></tt>
| Hides the edit links beside headings.
| {{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> &rarr; {{NUMBEROFPAGES}} and <code><tt><nowiki>{{NUMBEROFPAGES:R}}</nowiki></tt></code> &rarr; {{NUMBEROFPAGES:R}}).
! Word !! Example !! Explanation
 
{| class="wikitable"
! Variable
! Output
! Description
|-
|-
| <nowiki>{{CURRENTDAY}}</nowiki>
| colspan="3"| '''Entire wiki'''
| <code>{{CURRENTDAY}}</code>
| Displays the current day in numeric form.
|-
|-
| <nowiki>{{CURRENTDAYNAME}}</nowiki>
| <tt><nowiki>{{NUMBEROFPAGES}}</nowiki></tt>
| <code>{{CURRENTDAYNAME}}</code>
| {{NUMBEROFPAGES}}
| Displays the current day in named form.
| Number of wiki pages.
|-
|-
| <nowiki>{{CURRENTDOW}}</nowiki>
| <tt><nowiki>{{NUMBEROFARTICLES}}</nowiki></tt>
| <code>{{CURRENTDOW}}</code>
| {{NUMBEROFARTICLES}}
| Displays the current day as a number of the week (0=Sunday, 1=Monday...).
| Number of pages in main namespace without Main Page.
|-
|-
| <nowiki>{{CURRENTMONTH}}</nowiki>
| <tt><nowiki>{{NUMBEROFFILES}}</nowiki></tt>
| <code>{{CURRENTMONTH}}</code>
| {{NUMBEROFFILES}}
| Displays the current month in numeric form.
| Number of uploaded files.
|-
|-
| <nowiki>{{CURRENTMONTHABBREV}}</nowiki>
| <tt><nowiki>{{NUMBEROFUSERS}}</nowiki></tt>
| <code>{{CURRENTMONTHABBREV}}</code>
| {{NUMBEROFUSERS}}
| Displays the abbreviation of the current month.
| Number of registered users.
|-
|-
| <nowiki>{{CURRENTMONTHNAME}}</nowiki>
| <tt><nowiki>{{NUMBEROFADMINS}}</nowiki></tt>
| <code>{{CURRENTMONTHNAME}}</code>
| {{NUMBEROFADMINS}}
| Displays the current month in named form.
| Number of sysops.
|}
 
====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>{{CURRENTHOUR}}</nowiki>
| <tt><nowiki>{{BASEPAGENAME}}</nowiki></tt>
| <code>{{CURRENTHOUR}}</code>
| {{BASEPAGENAME}}
| Displays the current hour in numeric form.
| Page title excluding the current subpage and namespace ("Title/Page" on "Help:Title/Page/Subpage").
|-
|-
| <nowiki>{{CURRENTWEEK}}</nowiki>
| <tt><nowiki>{{SUBPAGENAME}}</nowiki></tt>
| <code>{{CURRENTWEEK}}</code>
| {{SUBPAGENAME}}
| Displays the number of the current week (1-52).
| The subpage title ("Subpage" on "Help:Title/Page/Subpage").
|-
|-
| <nowiki>{{CURRENTYEAR}}</nowiki>
| <tt><nowiki>{{SUBJECTPAGENAME}}</nowiki></tt>
| <code>{{CURRENTYEAR}}</code>
| {{SUBJECTPAGENAME}}
| Returns the current year.
| The namespace and title of the associated content page.
|}<br clear="all" />
|-
| <tt><nowiki>{{TALKPAGENAME}}</nowiki></tt>
| {{TALKPAGENAME}}
| The namespace and title of the associated talk page.
|}


== Page names, locations, and URLs ==
The <tt><nowiki>{{BASEPAGENAME}}</nowiki></tt> and <tt><nowiki>{{SUBPAGENAME}}</nowiki></tt> magic words only work in namespaces that have subpages enabled.
{| border="2" cellpadding="4" cellspacing="0" style="margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse;"
 
! Word !! Example !! Explanation
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>
 
====Namespaces====
{| class="wikitable"
! Variable
! Output
! Description
|-
| <tt><nowiki>{{NAMESPACE}}</nowiki></tt>
| {{NAMESPACE}}
| Namespace (name)
|-
|-
| <nowiki>{{PAGENAME}}</nowiki>
| <tt><nowiki>{{SUBJECTSPACE}}</nowiki></tt><br /><tt><nowiki>{{ARTICLESPACE}}</nowiki></tt>
| <code>{{PAGENAME}}</code>
| {{SUBJECTSPACE}}<br />{{ARTICLESPACE}}
| Returns the name of the current page, including all levels (Title/Subtitle/Sub-subtitle).
| Name of the associated content namespace
|-
|-
| <nowiki>{{PAGENAMEE}}</nowiki>
| <tt><nowiki>{{TALKSPACE}}</nowiki></tt>
| <code>{{PAGENAMEE}}</code>
| {{TALKSPACE}}
| More URL-friendly percent encoded special characters (rarely necessary).
| 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>{{SUBPAGENAME}}</nowiki><br /><nowiki>{{SUBPAGENAMEE}}</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>{{SUBPAGENAME}}<br />{{SUBPAGENAMEE}}</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}}
| Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages.
| The relative path to the title.  
|-
|-
| <nowiki>{{BASEPAGENAME}}</nowiki><br ><nowiki>{{BASEPAGENAMEE}}</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>{{BASEPAGENAME}}<br />{{BASEPAGENAMEE}}</code>
| <nowiki>{{fullurl:Help:Magic Words}}</nowiki> {{fullurl:Help:Magic Words}}<br />
| The basename of a subpage ("Title/Other" on "Title/Other/Subtitle").
<nowiki>{{fullurl:Help:Magic Words|action=edit}}</nowiki> → {{fullurl:Help:Magic Words|action=edit}}
| The absolute path to the title.
|-
|-
| <nowiki>{{NAMESPACE}}</nowiki>
| <tt><nowiki>{{urlencode:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{NAMESPACE}}</code>
| <nowiki>{{urlencode:x y z}}</nowiki> → {{urlencode:x y z}}
| Returns the name of the namespace the current page resides in.
| The input encoded for use in URLs.
|-
|-
| <nowiki>{{FULLPAGENAME}}</nowiki><br ><nowiki>{{FULLPAGENAMEE}}</nowiki>
| <tt><nowiki>{{anchorencode:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{FULLPAGENAME}}<br />{{FULLPAGENAMEE}}</code>
| <nowiki>{{anchorencode:x y z}}</nowiki> → {{anchorencode:x y z}}
| Shorthands for NAMESPACE+PAGENAME
| 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>{{TALKSPACE}}</nowiki><br ><nowiki>{{TALKSPACEE}}</nowiki>
! Usage
| <code>{{TALKSPACE}}<br />{{TALKSPACEE}}</code>
! Output
| Name of next odd namespace (e.g. 4 =&gt; 5) 
! Usage
! Output
|-
|-
| <nowiki>{{SUBJECTSPACE}}</nowiki><br ><nowiki>{{SUBJECTSPACEE}}</nowiki>
| <tt><nowiki>{{ns:-2}}</nowiki></tt> or <tt><nowiki>{{ns:Media}}</nowiki></tt>
| <code>{{SUBJECTSPACE}}<br />{{SUBJECTSPACEE}}</code>
| {{ns:-2}}
| Name of last even namespace (e.g. 5 =&gt; 4)
| <tt><nowiki>{{ns:-1}}</nowiki></tt> or <tt><nowiki>{{ns:Special}}</nowiki></tt>
| {{ns:-1}}
|-
|-
| <nowiki>{{ARTICLESPACE}}</nowiki><br ><nowiki>{{ARTICLESPACEE}}</nowiki>
| <tt><nowiki>{{ns:0}}</nowiki></tt>
| <code>{{ARTICLESPACE}}<br />{{ARTICLESPACEE}}</code>
| {{ns:0}}
| An alias for SUBJECTSPACE(E)
| <tt><nowiki>{{ns:1}}</nowiki></tt> or <tt><nowiki>{{ns:Talk}}</nowiki></tt>
| {{ns:1}}
|-
|-
| <nowiki>{{TALKPAGENAME}}</nowiki><br ><nowiki>{{TALKPAGENAMEE}}</nowiki>
| <tt><nowiki>{{ns:2}}</nowiki></tt> or <tt><nowiki>{{ns:User}}</nowiki></tt>
| <code>{{TALKPAGENAME}}<br />{{TALKPAGENAMEE}}</code>
| {{ns:2}}
| FULLPAGENAME in its TALKSPACE
| <tt><nowiki>{{ns:3}}</nowiki></tt> or <tt><nowiki>{{ns:User talk}}</nowiki></tt>
| {{ns:3}}
|-
|-
| <nowiki>{{SUBJECTPAGENAME}}</nowiki><br ><nowiki>{{SUBJECTPAGENAMEE}}</nowiki>
| <tt><nowiki>{{ns:4}}</nowiki></tt> or <tt><nowiki>{{ns:Project}}</nowiki></tt>
| <code>{{SUBJECTPAGENAME}}<br />{{SUBJECTPAGENAMEE}}</code>
| {{ns:4}}
| FULLPAGENAME in its SUBJECTSPACE
| <tt><nowiki>{{ns:5}}</nowiki></tt> or <tt><nowiki>{{ns:Project talk}}</nowiki></tt>
| {{ns:5}}
|-
|-
| <nowiki>{{ARTICLEPAGENAME}}</nowiki><br ><nowiki>{{ARTICLEPAGENAMEE}}</nowiki>
| <tt><nowiki>{{ns:6}}</nowiki></tt> or <tt><nowiki>{{ns:File}}</nowiki></tt> or <tt><nowiki>{{ns:Image}}</nowiki></tt>
| <code>{{ARTICLEPAGENAME}}<br />{{ARTICLEPAGENAMEE}}</code>
| {{ns:6}}
| An alias for SUBJECTPAGENAME(E)
| <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>{{REVISIONID}}</nowiki>
| <tt><nowiki>{{ns:8}}</nowiki></tt> or <tt><nowiki>{{ns:MediaWiki}}</nowiki></tt>
| <code>{{REVISIONID}}</code>
| {{ns:8}}
| Gives you the unique identifying number of the article or diff database.
| <tt><nowiki>{{ns:9}}</nowiki></tt> or <tt><nowiki>{{ns:MediaWiki talk}}</nowiki></tt>
| {{ns:9}}
|-
|-
| <nowiki>{{REVISIONDAY}}</nowiki>
| <tt><nowiki>{{ns:10}}</nowiki></tt> or <tt><nowiki>{{ns:Template}}</nowiki></tt>
| <code>{{REVISIONDAY}}</code>
| {{ns:10}}
| The day on which the page was last modified.
| <tt><nowiki>{{ns:11}}</nowiki></tt> or <tt><nowiki>{{ns:Template talk}}</nowiki></tt>
| {{ns:11}}
|-
|-
| <nowiki>{{REVISIONDAY2}}</nowiki>
| <tt><nowiki>{{ns:12}}</nowiki></tt> or <tt><nowiki>{{ns:Help}}</nowiki></tt>
| <code>{{REVISIONDAY2}}</code>
| {{ns:12}}
| The day on which the page was last modified, but with a leading zero (01 .. 31).
| <tt><nowiki>{{ns:13}}</nowiki></tt> or <tt><nowiki>{{ns:Help talk}}</nowiki></tt>
| {{ns:13}}
|-
|-
| <nowiki>{{REVISIONMONTH}}</nowiki>
| <tt><nowiki>{{ns:14}}</nowiki></tt> or <tt><nowiki>{{ns:Category}}</nowiki></tt>
| <code>{{REVISIONMONTH}}</code>
| {{ns:14}}
| The month 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>{{REVISIONYEAR}}</nowiki>
| <tt><nowiki>{{lc:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{REVISIONYEAR}}</code>
| <tt><nowiki>{{lc:TEXT TRANSFORM}}</nowiki></tt> → {{lc:TEXT TRANSFORM}}
| The year in which the page was last modified.
| The lowercase input.
|-
|-
| <nowiki>{{REVISIONTIMESTAMP}}</nowiki>
| <tt><nowiki>{{lcfirst:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{REVISIONTIMESTAMP}}</code>
| <tt><nowiki>{{lcfirst:TEXT TRANSFORM}}</nowiki></tt> → {{lcfirst:TEXT TRANSFORM}}
| [[wikipedia:ISO 8601|ISO 8601]] time stamp, indicating when the page was last modified.
| The input with the <u>very first</u> character lowercase.
|-
|-
| <nowiki>{{SITENAME}}</nowiki>
| <tt><nowiki>{{uc:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <code>{{SITENAME}}</code>
| <tt><nowiki>{{uc:text transform}}</nowiki></tt> → {{uc:text transform}}
| Returns the name of the wiki (set in <tt>LocalSettings.php</tt>).
| The uppercase input.
|-
|-
| <nowiki>{{NS:}}</nowiki>
| <tt><nowiki>{{ucfirst:</nowiki>''string''<nowiki>}}</nowiki></tt>
| <nowiki>{{NS:4}}</nowiki> = <code>{{NS:4}}</code><br /><nowiki>{{NS:PROJECT}}</nowiki> = <code>{{NS:PROJECT}}</code>
| <tt><nowiki>{{ucfirst:text transform}}</nowiki></tt> {{ucfirst:text transform}}
| Returns the name of a given [[UDWiki:Namespaces|namespace number]].
| The input with the <u>very first</u> character uppercase.
|-
|-
| <nowiki>{{LOCALURL:x y}}</nowiki><br /><nowiki>{{LOCALURLE:%}}</nowiki>
| <tt><nowiki>{{formatnum:</nowiki>''unformatted&nbsp;num''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{formatnum:</nowiki>''formatted&nbsp;num''<nowiki>|R}}</nowiki></tt>
| <code>{{localurl:x y}}<br />{{localurle:%}}</code>
| <tt><nowiki>{{formatnum:-987654321.654321}}</nowiki></tt> {{formatnum:-987654321.654321}}
| Returns the local URL of a given page. The page might not exist.
| Formats a number.
|-
|-
| <nowiki>{{SERVER}}</nowiki>
| <tt><nowiki>{{padleft:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{padleft:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></tt>
| <small>{{SERVER}}</small>
| <tt><nowiki>{{padleft:xyz|5}}</nowiki></tt> → {{padleft:xyz|5}}<br /> <tt><nowiki>{{padleft:xyz|5|_}}</nowiki></tt> → {{padleft:xyz|5|_}}
| Returns the domain and subdomain URL of the wiki.
| 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>{{SCRIPTPATH}}</nowiki>
| <tt><nowiki>{{padright:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></tt><br /><tt><nowiki>{{padright:xyz|</nowiki>''strlen''<nowiki>|</nowiki>''char''<nowiki>}}</nowiki></tt>
| <code>{{SCRIPTPATH}}</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 $wgScriptPath in <tt>LocalSettings.php</tt>.
| Identical to padleft, but adds padding characters to the right side.
|-
|-
| <nowiki>{{SERVERNAME}}</nowiki>
| <tt><nowiki>{{plural:2|</nowiki>''is''<nowiki>|</nowiki>''are''<nowiki>}}</nowiki></tt>
| <code>{{SERVERNAME}}</code>
| <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}}
| Returns the value of $wgServerName in <tt>LocalSettings.php</tt>.
| 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}}
{{Template:EditHelpMenu}}

Revision as of 17:01, 2 August 2009

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}} 2024 Year
Month
{{CURRENTMONTH}} 06 Month (zero-padded number)
{{CURRENTMONTHNAME}} June Month (name)
{{CURRENTMONTHNAMEGEN}} June Month (genitive form)
{{CURRENTMONTHABBREV}} Jun Month (abbreviation)
Day
{{CURRENTDAY}} 1 Day of the month (unpadded number)
{{CURRENTDAY2}} 01 Day of the month (zero-padded number)
{{CURRENTDOW}} 6 Day of the week (Sunday = 0 thru Saturday=6)
{{CURRENTDAYNAME}} Saturday Day of the week (name)
Time
{{CURRENTTIME}} 10:04 Time (24-hour HH:mm format)
{{CURRENTHOUR}} 10 Hour (24-hour zero-padded number)
Other
{{CURRENTWEEK}} 22 Week (number)
{{CURRENTTIMESTAMP}} 20240601100420 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.1 The wiki's MediaWiki version.
Latest revision to current page
{{REVISIONID}} 1530457 Unique revision ID
{{REVISIONDAY}} 2 Day edit was made (unpadded number)
{{REVISIONDAY2}} 02 Day edit was made (zero-padded number)
{{REVISIONMONTH}} 08 Month edit was made (unpadded number)
{{REVISIONYEAR}} 2009 Year edit was made
{{REVISIONTIMESTAMP}} 20090802170107 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,206 and {{NUMBEROFPAGES:R}} → 152206).

Variable Output Description
Entire wiki
{{NUMBEROFPAGES}} 152,206 Number of wiki pages.
{{NUMBEROFARTICLES}} 19,389 Number of pages in main namespace without Main Page.
{{NUMBEROFFILES}} 22,058 Number of uploaded files.
{{NUMBEROFUSERS}} 51,147 Number of registered users.
{{NUMBEROFADMINS}} 7 Number of sysops.

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