Open main menu

lensowiki β

Changes

Help:Magic words

17,341 bytes added, 12:12, 17 July 2006
Project-dependent word conversions: language-dependent, not really project dependent except maybe in a confusing sense
{{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>__NOGALLERY__</nowiki>
| '''[MW1.7+]''' This magic word allows images in category pages to be displayed as inline links instead of gallery.
|-
| <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" />

== Variables ==
:''For details see [[Help:Variable]]''

===Time===
{| 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.6+]''' 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) according to [[w:en:ISO 8601|ISO 8601]] with no leading zero.
|-
| <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.
|}{{-}}

=== Statistics ===
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Example
! Explanation
|-
| <nowiki>{{CURRENTVERSION}}</nowiki>
| <code>{{CURRENTVERSION}}</code>
| '''[MW1.7+]''' {{h:mwg|Version}} [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>{{NUMBEROFADMINS}}</nowiki><br /><nowiki>{{NUMBEROFADMINS:R}}</nowiki>
| <code>{{NUMBEROFADMINS}}</code><br /><code>{{NUMBEROFADMINS:R}}</code>
| '''[MW1.7+]''' Returns the number of administrators (sysop, bureaucrat, steward and checkuser).
|-
| <nowiki>{{PAGESINNAMESPACE}}</nowiki>
| &#160;{{#if:{{#ifexpr:{{PAGEINNS:0|R}}}}|<font color="red">'''disabled here'''</font>}}
| Longer alias of PAGESINNS
|-
| <nowiki>{{PAGESINNS:ns}}</nowiki><br /><nowiki>{{PAGESINNS:ns:R}}</nowiki>
| <nowiki>{{PAGESINNS:2}}</nowiki>&#160;{{#if:{{#ifexpr:{{PAGEINNS:0|R}}}}||=&#160;<tt>{{PAGESINNS:2}}</tt>}}<br /><nowiki>{{PAGESINNS:2|R}}</nowiki>&#160;{{#if:{{#ifexpr:{{PAGEINNS:0|R}}}}|<br /><font color="red">'''disabled here'''</font>|=&#160;<tt>{{PAGESINNS:2|R}}</tt>}}
| '''[MW1.7+]''' Returns the number of pages in the given namespace. Disabled by default, enable with {{h:mwg|AllowSlowParserFunctions}}.
|}{{-}}


=== Page names and related info ===
{| 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).
|-
| <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+]''' Name of the current page, excluding parent pages ("Subtitle" on "Title/Subtitle") in namespaces supporting subpages, see [[Help:Link#Subpage_feature|Help:Link]].
|-
| <nowiki>{{BASEPAGENAME}}</nowiki><br ><nowiki>{{BASEPAGENAMEE}}</nowiki>
| <code>{{BASEPAGENAME}}<br />{{BASEPAGENAMEE}}</code>
| '''[MW1.7+]''' The basename of a subpage ("Title" on "Title/Subtitle"), see [[Help:Link#Subpage_feature|Help:Link]].
|-
| <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>{{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)
|-
| <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 {{h:mwg|Sitename}}.
|-
| <nowiki>{{SERVER}}</nowiki>
| <small>{{SERVER}}</small>
| Value of {{h:mwg|Server}}
|-
| <nowiki>{{SCRIPTPATH}}</nowiki>
| <code>{{SCRIPTPATH}}</code>
| '''[MW1.5+]''' {{h:mwg|ScriptPath}}
|-
| <nowiki>{{SERVERNAME}}</nowiki>
| <code>{{SERVERNAME}}</code>
| '''[MW1.5+]''' {{h:mwg|ServerName}}
|-
|}{{-}}

==Colon functions==

:''For details see [[Help:Colon function]].''

=== Namespaces and URLs ===
{| class="wikitable" border="2" cellpadding="4" cellspacing="0"
! Word
! Example
! Explanation
|-
| <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:x y @}}</nowiki><br /><nowiki>{{localurl:a|b=c}}</nowiki>
| <code>{{localurl:x y @}}<br />{{localurle:x y @}}<br />{{localurl:a|b=c}}</code>
| Returns the local URL of a page (might not exist). Optional ''query'' parameter, see [[Help:Variable]].
|- <!-- intentionally nbsp instead of sp for formatting reasons -->
| <nowiki>{{urlencode:x&#160;y&#160;@}}</nowiki>
| <code>{{urlencode:x y @}}</code>
| '''[MW1.7+]''' Encodes variable values for use in external links. [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=14273]
|-
| <nowiki>{{fullurl:x y @}}</nowiki><br /><nowiki>{{fullurle:x y @}}</nowiki><br /><nowiki>{{fullurl:m:a|b=c}}</nowiki>
| <small>{{fullurl:x y @}}<br />{{fullurle:x y @}}<br />{{fullurl:m:a|b=c}}</small>
| '''[MW1.5+]''' Returns the full URL of a given page. Optional ''query'' parameter as for <tt>localurl:</tt>.
|}{{-}}

=== Formatting ===
{| class="wikitable" border="2" cellpadding="4" cellspacing="0" width="100%"
! Word
! Example
! Explanation
|-
| <nowiki>{{#language:}}</nowiki>
| <nowiki>{{#language:da}}</nowiki> = <code>{{#language:da}}</code>
| '''[MW1.7+]''' Native name of language code.
|-
| <nowiki>{{lc:}}</nowiki>
| <nowiki>{{lc:AbC dEf}}</nowiki> = <code>{{lc:AbC dEf}}</code>
| '''[MW1.5+]''' LowerCase
|-
| <nowiki>{{lcfirst:}}</nowiki>
| <nowiki>{{lcfirst:Ab Cd}}</nowiki> = <code>{{lcfirst:Ab Cd}}</code>
| '''[MW1.5+]''' LC first char.
|-
| <nowiki>{{uc:}}</nowiki>
| <nowiki>{{uc:aBc DeF}}</nowiki> = <code>{{uc:aBc DeF}}</code>
| '''[MW1.5+]''' UpperCase
|-
| <nowiki>{{ucfirst:}}</nowiki>
| <nowiki>{{ucfirst:aB cD}}</nowiki> = <code>{{ucfirst:aB cD}}</code>
| '''[MW1.5+]''' UC first char.
|-
| <nowiki>{{formatnum:}}</nowiki>
| <nowiki>{{formatnum:299792458}}</nowiki> = <code>{{formatnum:299792458}}</code>
| '''[MW1.7+]''' Add decimal separators according to the wiki's default locale.
|}{{-}}

== 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]].
|}{{-}}

== 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=Wiki.png]]</nowiki>
| Manualthumb: instead of displaying an automatically-sized thumbnail for <var>Mediawiki.png</var>, display the image <var>Wiki.png</var>.
|-
| ''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>''xyz''<nowiki>}}</nowiki>
| <font color="red">'''default disabled'''</font>
| '''[MW 1.7+]''' Set the page's title [http://svn.wikimedia.org/viewvc/mediawiki?view=rev&revision=13572], see {{h:mwg|AllowDisplayTitle}}.
|-
| <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>{{CONTENTLANGUAGE}}</nowiki>
| <code>{{CONTENTLANGUAGE}}</code>
| '''[MW1.7+]''' Default content {{h:mwg|LanguageCode}}
|-
| <nowiki>#redirect</nowiki>
| <code>#REDIRECT&#160;[&#91;target&#93;]</code><br />at top of source page
| Creates a [[Help:Redirect|redirect]] to another page.
|}{{-}}

===Language-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 month name used for Czech, Polish, Ukrainian[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 language-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|enname=Magic words}}
Anonymous user