Help:Magic words: Difference between revisions

Content deleted Content added
Omniplex (talk | contribs)
Miscellany: s/nl/da/ (sorry, coluimn width), add DIRMARK
m Reverted change by 2806:2F0:4620:FE83:6CFD:BC10:8A87:AF94 (talk) to last version by Tegel
Tag: Rollback
 
(455 intermediate revisions by more than 100 users not shown)
Line 1:
{{MovedToMediaWiki}}
{{H:h|editor toc}}
This is an organised index of Magic words used in MediaWiki. Tags such as "'''[MW1.5+]'''" indicate the version that first supported the magic word. "XYZ" indicates user input, which is used in the example.
 
== Table of contents ==
:''For details see [[Help:Section]]''
{| class="wikitable" border="2" cellpadding="4" cellspacing="0" width="79%"
! Word
! Explanation
|-
| <nowiki>__NOTOC__</nowiki>
| Hides ToC on the current page.
|-
|<nowiki>__FORCETOC__</nowiki>
| Forces the table of contents to appear.
|-
| <nowiki>__TOC__</nowiki>
| Places a ToC here (overriding any <nowiki>__NOTOC__</nowiki>).
|}<br clear="left" />
 
== More magic ==
{| class="wikitable" border="2" cellpadding="4" cellspacing="0" width="79%"
! Word
! Explanation
|-
| <nowiki>__NOEDITSECTION__</nowiki>
| Hides the edit links beside headings.
|-
| <nowiki>__NEWSECTIONLINK__</nowiki>
| '''[MW1.7+]''' Gives a "+"-link next to the edit-tab to make a new section on a non-talk page.
|-
| <nowiki>__NOCONTENTCONVERT__</nowiki><br /><nowiki>__NOCC__</nowiki>
| Don't perform the content language conversion (character and phase) in article display; for example, Chinese zh with zh_cn, zh_tw, zh_sg, zh_hk.
|-
| <nowiki>__NOTITLECONVERT__</nowiki><br /><nowiki>__NOTC__</nowiki>
| Like <nowiki>__NOCC__</nowiki> but affecting article title only.
|-
| <nowiki>__END__</nowiki>
| Allows for trailing whitespace to be included in the page save.
|-
| <nowiki>__START__</nowiki>
| This magic word has no effect but an ID in <tt>MagicWord.php</tt> (<code>MAG_START</code>).
|}<br clear="left" />
 
== Formatting ==
:''For details see [[Help:Colon function]]''
{| class="wikitable" border="2" cellpadding="4" cellspacing="0" width="79%"
! Word
! Example
! Explanation
|-
| <nowiki>{{lc:}}</nowiki>
| <nowiki>{{lc:AbC dEf}}</nowiki> = <code>{{lc:AbC dEf}}</code>
| '''[MW1.5+]''' LowerCase
|-
| <nowiki>{{uc:}}</nowiki>
| <nowiki>{{uc:aBc DeF}}</nowiki> = <code>{{uc:aBc DeF}}</code>
| '''[MW1.5+]''' UpperCase
|-
| <nowiki>{{lcfirst:}}</nowiki>
| <nowiki>{{lcfirst:Ab Cd}}</nowiki> = <code>{{lcfirst:Ab Cd}}</code>
| '''[MW1.5+]''' LC first char.
|-
| <nowiki>{{ucfirst:}}</nowiki>
| <nowiki>{{ucfirst:aB cD}}</nowiki> = <code>{{ucfirst:aB cD}}</code>
| '''[MW1.5+]''' UC first char.
|}{{-}}
 
== Template modifiers ==
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Usage
! Explanation
|-
| <nowiki>{{:xyz}}</nowiki>
| A bare colon is no template modifier, it's the prefix for the main namespace. Test e.g. article {&#123;:UTC&#125;} vs. template {&#123;UTC&#125;}
|-
| <nowiki>{{int:xyz}}</nowiki>
| Shorthand for <nowiki>{{MediaWiki:xyz}}</nowiki>, rendered as {{int:xyz}} if [[MediaWiki:xyz]] doesn't exist. See [[Help:MediaWiki namespace]].
|-
| <nowiki>{{msg:xyz}}</nowiki>
| Try <nowiki>{{Template:xyz}}</nowiki> before [[Help:Magic words|magic word]] xyz, without this modifier it's the other way around. No additional effect if there is no template xyz.
|-
| <nowiki>{{msgnw:xyz}}</nowiki>
| The unevaluated wikitext is rendered. See [[Help:Template#msgnw|msgnw]].
|-
| <nowiki>{{raw:xyz}}</nowiki>
| '''[MW1.6+]''' Like <code>{&#123;msg:&#125;}</code> {{unclear}} [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=12925]
|-
| <nowiki>{{subst:xyz}}</nowiki>
| In the wikitext, the tag is substituted by the ''content'' (single-level evaluation only), see [[Help:Substitution]].
|}{{-}}
 
== Time ==
:''For details see [[Help:Variable]]''
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Example
! Explanation
|-
| <nowiki>{{CURRENTDAY}}</nowiki>
| <code>{{CURRENTDAY}}</code>
| Displays the current day in numeric form.
|-
| <nowiki>{{CURRENTDAY2}}</nowiki>
| <code>{{CURRENTDAY2}}</code>
| '''[MW1.5+]''' Ditto with leading zero 01 .. 31).
|-
| <nowiki>{{CURRENTDAYNAME}}</nowiki>
| <code>{{CURRENTDAYNAME}}</code>
| Name of the day in the language of the project or English.
|-
| <nowiki>{{CURRENTDOW}}</nowiki>
| <code>{{CURRENTDOW}}</code>
| Ditto as number (0=Sunday, 1=Monday...).
|-
| <nowiki>{{CURRENTMONTH}}</nowiki>
| <code>{{CURRENTMONTH}}</code>
| The number 01 .. 12 of the month.
|-
| <nowiki>{{CURRENTMONTHABBREV}}</nowiki>
| <code>{{CURRENTMONTHABBREV}}</code>
| '''[MW1.5+]''' Ditto abbreviated Jan .. Dec.
|-
| <nowiki>{{CURRENTMONTHNAME}}</nowiki>
| <code>{{CURRENTMONTHNAME}}</code>
| Ditto in named form January .. December.
|-
| <nowiki>{{CURRENTTIME}}</nowiki>
| <code>{{CURRENTTIME}}</code>
| The current time (00:00 .. 23:59).
|-
| <nowiki>{{CURRENTWEEK}}</nowiki>
| <code>{{CURRENTWEEK}}</code>
| Number of the current week (1-53).
|-
| <nowiki>{{CURRENTYEAR}}</nowiki>
| <code>{{CURRENTYEAR}}</code>
| Returns the current year.
|-
| <nowiki>{{CURRENTTIMESTAMP}}</nowiki>
| <code>{{CURRENTTIMESTAMP}}</code>
| '''[MW1.7+]''' [[w:en:ISO 8601|ISO 8601]] time stamp.
|}{{-}}
 
== Page names, locations, and URLs ==
:''For details see [[Help:Variable]]''
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Example
! Explanation
|-
| <nowiki>{{PAGENAME}}</nowiki>
| <code>{{PAGENAME}}</code>
| Returns the name of the current page, including all levels (Title/Subtitle/Sub-subtitle).
|-
| <nowiki>{{PAGENAMEE}}</nowiki>
| <code>{{PAGENAMEE}}</code>
| More URL-friendly percent encoded special characters (To use an articlename in an external link).
|-
| <nowiki>{{SUBPAGENAME}}</nowiki><br /><nowiki>{{SUBPAGENAMEE}}</nowiki>
| <code>{{SUBPAGENAME}}<br />{{SUBPAGENAMEE}}</code>
| '''[MW1.6+]''' Returns the name of the current page, excluding parent pages ("Title/Subtitle" becomes "Subtitle").
|-
| <nowiki>{{BASEPAGENAME}}</nowiki><br ><nowiki>{{BASEPAGENAMEE}}</nowiki>
| <code>{{BASEPAGENAME}}<br />{{BASEPAGENAMEE}}</code>
| '''[MW1.7+]''' The basename of a subpage ("Title/Subtitle" becomes "Title")
|-
| <nowiki>{{NAMESPACE}}</nowiki><br /><nowiki>{{NAMESPACEE}}</nowiki>
| <code>{{NAMESPACE}}<br />{{NAMESPACEE}}</code>
| Returns the name of the namespace the current page resides in.
|-
| <nowiki>{{FULLPAGENAME}}</nowiki><br ><nowiki>{{FULLPAGENAMEE}}</nowiki>
| <code>{{FULLPAGENAME}}<br />{{FULLPAGENAMEE}}</code>
| '''[MW1.6+]''' Shorthands for NAMESPACE+PAGENAME
|-
| <nowiki>{{REVISIONID}}</nowiki>
| <code>{{REVISIONID}}</code>
| '''[MW1.5+]''' The unique identifying number of a page, see [[Help:Diff]].
|-
| <nowiki>{{SITENAME}}</nowiki>
| <code>{{SITENAME}}</code>
| Value of [[mw:Help:$wgSiteName|$wgSitename]].
|-
| <nowiki>{{ns:}}</nowiki>
| <nowiki>{{ns:4}}</nowiki> = <code>{{ns:4}}</code><br /><nowiki>{{ns:project}}</nowiki> = <code>{{ns:project}}</code>
| Returns the name of a given [[Help:Namespace|namespace number]].
|-
| <nowiki>{{localurl:x y}}</nowiki><br /><nowiki>{{localurle:%}}</nowiki>
| <code>{{localurl:x y}}<br />{{localurle:%}}</code>
| Returns the local URL of a given page. The page might not exist.
|-
| <nowiki>{{urlencode: x y %@ }}</nowiki>
| {{URLENCODE: x y %@ }}
| '''[MW1.7+]''' To use a variable (parameter in a template) with spaces in an external link. [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=14273]
|-
| <nowiki>{{SERVER}}</nowiki>
| <small>{{SERVER}}</small>
| Value of [[mw:Help:$wgServer|$wgServer]]
|-
| <nowiki>{{fullurl:x y}}</nowiki><br /><nowiki>{{fullurle:x y}}</nowiki>
| <small>{{fullurl:x y}}<br />{{fullurle:x y}}</small>
| '''[MW1.5+]''' Returns the full URL of a given page.
|-
| <nowiki>{{SCRIPTPATH}}</nowiki>
| <code>{{SCRIPTPATH}}</code>
| '''[MW1.5+]''' [[mw:Help:$wgScriptPath|$wgScriptPath]].
|-
| <nowiki>{{SERVERNAME}}</nowiki>
| <code>{{SERVERNAME}}</code>
| '''[MW1.5+]''' [[mw:Help:$wgServerName|$wgServerName]].
|-
| <nowiki>{{TALKSPACE}}</nowiki><br ><nowiki>{{TALKSPACEE}}</nowiki>
| <code>{{TALKSPACE}}<br />{{TALKSPACEE}}</code>
| '''[MW1.7+]''' Name of next odd namespace (e.g. 4 =&gt; 5)
|-
| <nowiki>{{SUBJECTSPACE}}</nowiki><br ><nowiki>{{SUBJECTSPACEE}}</nowiki>
| <code>{{SUBJECTSPACE}}<br />{{SUBJECTSPACEE}}</code>
| '''[MW1.7+]''' Name of next even namespace (e.g. 5 =&gt; 4)
|-
| <nowiki>{{ARTICLESPACE}}</nowiki><br ><nowiki>{{ARTICLESPACEE}}</nowiki>
| <code>{{ARTICLESPACE}}<br />{{ARTICLESPACEE}}</code>
| '''[MW1.7+]''' An alias for SUBJECTSPACE(E)
|-
| <nowiki>{{TALKPAGENAME}}</nowiki><br ><nowiki>{{TALKPAGENAMEE}}</nowiki>
| <code>{{TALKPAGENAME}}<br />{{TALKPAGENAMEE}}</code>
| '''[MW1.7+]''' FULLPAGENAME in its TALKSPACE
|-
| <nowiki>{{SUBJECTPAGENAME}}</nowiki><br ><nowiki>{{SUBJECTPAGENAMEE}}</nowiki>
| <code>{{SUBJECTPAGENAME}}<br />{{SUBJECTPAGENAMEE}}</code>
| '''[MW1.7+]''' FULLPAGENAME in its SUBJECTSPACE
|-
| <nowiki>{{ARTICLEPAGENAME}}</nowiki><br ><nowiki>{{ARTICLEPAGENAMEE}}</nowiki>
| <code>{{ARTICLEPAGENAME}}<br />{{ARTICLEPAGENAMEE}}</code>
| '''[MW1.7+]''' An alias for SUBJECTPAGENAME(E)
|}{{-}}
 
== Image modifiers ==
:''For details see [[w:en:Wikipedia:Extended image syntax]].''
These are [[Help:Image page|image]] modifiers used in <code><nowiki>[[Image:title.ext|modifier|...|modifier]]</nowiki></code> links. Some are mutually exclusive, and then the last specified wins.
 
=== Size ===
The last unrecognized modifier is used as '''caption''' for ''framed'' images or together with ''thumbnail''s. It's also used as description <tt>alt=</tt>''text''.
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Usage
! Explanation
|-
| framed<br />frame<br />enframed
| <nowiki>[[Image:Mediawiki.png|framed]]</nowiki>
| Places an image in a ''frame'' with a description. Uses original size.
|-
| thumbnail<br />thumb
| <nowiki>[[Image:Mediawiki.png|thumbnail]]</nowiki>
| Modifies image size, sets it to dependant on user's favourite thumbnail size in their preferences.
|-
| thumb=''xyz''
| <nowiki>[[Image:Mediawiki.png|thumb=0]]</nowiki>
| Manualthumb {{unclear}}
|-
| ''width'' px
| <nowiki>[[Image:Mediawiki.png|40px]]</nowiki>
| Scales image to given ''width''&#160; in pixels
|}{{-}}
 
=== Position ===
:''For details see [[Help:Images_and_other_uploaded_files]]''
The positions are mutually exclusive, the last specified wins. [[:Template:-]] can stop floating. For inline images only modifier ''px'' (see above) is supported.
{| class="wikitable" border="2" cellpadding="4" cellspacing="0" width="100%"
! Word
! Usage
! Explanation
|-
| right
| <nowiki>[[Image:Mediawiki.png|right]]</nowiki>
| Modifies position, floats the image to the right.
|-
| <nowiki>left</nowiki>
| <nowiki>[[Image:Mediawiki.png|left]]</nowiki>
| Modifies position, floats the image to the left.
|-
| <nowiki>none</nowiki>
| <nowiki>[[Image:Mediawiki.png|none]]</nowiki>
| Explicitly states that the image should not float.
|-
| center<br />centre
| <nowiki>[[Image:Mediawiki.png|center]]</nowiki>
| Modifies position, like ''none'' but centered.
|}{{-}}
 
== Miscellany ==
 
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Example
! Explanation
|-
| <nowiki>{{DISPLAYTITLE}}</nowiki>
| <code>{{DISPLAYTITLE}}</code>&#160;
| '''[MW 1.7+]''' {{unclear}} [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=13572]
|-
| <nowiki>{{CURRENTVERSION}}</nowiki>
| <code>{{CURRENTVERSION}}</code>
| '''[MW1.7+]''' Returns the current version of MediaWiki being run. [http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-May/000026.html]
|-
| <nowiki>{{NUMBEROFARTICLES}}</nowiki><br /><nowiki>{{NUMBEROFARTICLES|R}}</nowiki>
| <code>{{NUMBEROFARTICLES}}</code><br /><code>{{NUMBEROFARTICLES|R}}</code>
| A [[Help:Variable|variable]] which returns the total number of articles on the Wiki.
|-
| <nowiki>{{NUMBEROFPAGES}}</nowiki><br /><nowiki>{{NUMBEROFPAGES|R}}</nowiki>
| <code>{{NUMBEROFPAGES}}</code><br /><code>{{NUMBEROFPAGES|R}}</code>
| '''[MW1.7+]''' Returns the total number of pages. [http://mail.wikipedia.org/pipermail/mediawiki-i18n/2006-May/000026.html]
|-
| <nowiki>{{NUMBEROFFILES}}</nowiki><br /><nowiki>{{NUMBEROFFILES|R}}</nowiki>
| <code>{{NUMBEROFFILES}}</code><br /><code>{{NUMBEROFFILES|R}}</code>
| '''[MW1.5+]''' Returns the number of uploaded files (rows in the image table).
|-
| <nowiki>{{NUMBEROFUSERS}}</nowiki><br /><nowiki>{{NUMBEROFUSERS|R}}</nowiki>
| <code>{{NUMBEROFUSERS}}</code><br /><code>{{NUMBEROFUSERS|R}}</code>
| '''[MW1.7+]''' Returns the number of registered users (rows in the user table).
|-
| <nowiki>{{DIRMARK}}</nowiki><br /><nowiki>{{DIRECTIONMARK}}</nowiki>
| <code>{{DIRMARK}}</code><br /><code>{{DIRECTIONMARK}}</code>
| '''[MW1.7+]''' u+200E left to right or u+200D right to left mark
|-
| <nowiki>{{#language:}}</nowiki>
| <nowiki>{{#language:da}}</nowiki> = {{#language:da}}
| Gives the local name of a language code.
|-
| <nowiki>#redirect</nowiki>
| <code>#REDIRECT&#160;[&#91;target&#93;]</code><br />at top of source page
| Creates a [[Help:Redirect|redirect]] to another page.
|}{{-}}
 
==Project-dependent word conversions==
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Example
! Explanation
|-
| {&#123;<small> CURRENTMONTHNAMEGEN </small>&#125;}
| <code>{{CURRENTMONTHNAMEGEN}}</code>
| [[w:genitive case|Genitive form]] of CURRENTMONTHNAME used for languages like {{unclear}} [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/]
|-
| {&#123;grammar:''case &#124; word'' &#125;}
| <nowiki>{{grammar:7sg|Wikipedie}}</nowiki><br />on [[:cs:]] is <code>Wikipedií</code>.
| Derived word forms in inflected languages like [[:cs:|Czech]] [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/LanguageCs.php]
|-
| {&#123;plural:''count &#124;form1 &#124;form2'' &#125;}<br />{&#123;plural:''count&#160;&#124;1st&#160;&#124;&#160;2nd&#160;&#124;&#160;3rd&#160;''&#125;}
| <nowiki>{{plural: 2 | is | are }}</nowiki><br />outputs <code>{{plural: 2 | is |are }}</code><br /><nowiki>{{plural: 0 | this | these }}</nowiki><br />outputs <code>{{plural: 0 |this | these }}</code>
| ''count'' '''1''' yields ''form1'' (singular), [[w:Plural|plural]] transformations are used for languages like [[:ru:|Russian]] [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/LanguageRu.php] based on "count mod 10".
|}{{-}}
 
"Grammar" and "Plural" are project-dependent functions, defined in [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/LanguageCs.php], [http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/LanguageRu.php], etc. (note that in PHP, the modulo operator is the percent sign).
 
"Grammar" can either be applied to predefined words only, or to arbitrary words, depending on whether the definition is just a 2D array, or involves string manipulations. See also [[:cs:Šablona:Wikivar/GRAMMAR]].
 
"Plural" is a project-dependent switch function, e.g. giving the first text if ''count'' = 1, the second if ''count'' = 2,3, or 4, and else the third.
See also [[mediazilla:5805]] for the use of "plural" in system messages.
 
==See also==
*[[m:ParserFunctions|Parser functions]] '''#expr:''', '''#if:''', '''#ifeq:''', etc.
*[http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/languages/Language.php Source for Language.php]
*[http://svn.wikimedia.org/svnroot/mediawiki/trunk/phase3/includes/MagicWord.php Source for MagicWord.php]
 
{{H:f|langs=|enname=Magic words}}