Nápověda:Systémové proměnné a jejich použití

Z DCEwiki
Skočit na navigaci Skočit na vyhledávání

Šablona:PD Help Page

Kouzelná slůvka (v orig. Magic words) jsou řetězce textu, místo kterých MediaWiki vrací nějakou návratovou hodnotu či funkci, např. aktuální čas, informace o stránce, nebo název stránky. Tato stránka se zaobírá jejich použitím. Pro jejich přehled čtěte Šablona:mediawiki.

General notes

  • Inheritance: page-dependent magic words will affect or return data about the current page, regardless of whether it is in the page code or a transcluded template.

Tabulka řetězců podle použití

A behaviour switch controls the layout or behaviour of the page. Většinou to jsou řetězce vymezené dvojitými podržítky.

Řetězec Popis Verze
Obsah
__NOTOC__ Skryje obsah (TOC).
__FORCETOC__ Vynutí vložení obsahu na jiné než obvyklé pozici (před prvním titulkem).
__TOC__ Umístí obsah na pozici tohoto řetězce (pozor, má vyšší prioritu než řetězec __NOTOC__ !). Je-li tento řetězec uveden ve stránce vícekrát, vygeneruje se obsah na místě prvního z nich.
Úpravy
__NOEDITSECTION__ Skryje pod titulkem linku pro úpravy.
__NEWSECTIONLINK__ Přidá odkaz (("+" by default) mezi záložku "editovat" tab for adding a new section on a non-talk page (see Šablona:mediawiki). 1.7+
Kategorie
__NOGALLERY__ Je-li použita na stránce která patří do jmenného prostoru Kategorie, vygenerují se místo náhledů normální odkazy. 1.7+
__HIDDENCAT__ Je-li použita na stránce, která patří mezi podkategorie, pak zajistí že se odkaz na tuto stránku u nadřazené kategorie nevygeneruje (pokud ovšem není tato volba negována na stavením v uživatelském nastavení). 1.13+
{{DEFAULTSORT:xyz}} Je-li použit tento řetězec na stránce která vypisuje kategorizované stránky, pak nastaví třídící klíč. 1.10+
Jazyková konverze
__NOCONTENTCONVERT__
__NOCC__
U stránek které mají více jazykových variant zamezí konverzi obsahu (character and phase) ve zobrazovaném článku; např. u Čínštiny zobrazí pouze zkratku (zh) místo převodu do zh_cn, zh_tw, zh_sg, nebo zh_hk.
__NOTITLECONVERT__
__NOTC__
U stránek které mají více jazykových variant zamezí konverzi nadpisu (zbylý obsah převede).
Formátování stránky
{{DISPLAYTITLE:xyz}} Format the current page's title header. The value must be equivalent to the default title: only capitalization changes and replacing spaces with underscores. It can be disabled or enabled by Šablona:mediawiki; disabled by default before 1.10+, enabled by default thereafter. 1.7+
__END__ Explicitly marks the end of the article, to prevent MediaWiki from removing trailing whitespace. Removed in Šablona:mediawiki.
Jiné
__START__ Nemá zatím žádný význam.
__NOINDEX__ Tell search engines not to index the page (ie, do not list in search engines' results). Šablona:mediawiki
__INDEX__ Tell search engines to index the page (overrides Šablona:mediawiki, but not robots.txt). 1.13+
__STATICREDIRECT__ On redirect pages, don't allow MediaWiki to automatically update the link when someone moves a page and checks "Update any redirects that point to the original title". Šablona:mediawiki
#REDIRECT [[Page name]] Causes the current page to redirect viewers to another page.

Proměnné a funkce

Variables return information about the current page, wiki, or date. Their syntax is similar to templates, but capitalized to help avoid conflicts. If a template has the same name and case as a variable, the variable will be used. Usage of the template can be forced by adding the "msg:" modifier (for example, "{{msg:CURRENTYEAR}}"). In some cases, adding parameters will force the parser to treat a variable as a template; for example, {{CURRENTDAYNAME|x}} tries to transclude "Template:CURRENTDAYNAME".

Parser functions are very similar to variables, but operate on user input instead of the current page. The first parameter is delimited by a colon (:) instead of a pipe (|). (This page does not document custom parser functions added by the Šablona:mediawiki.)

Datum & čas

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.

Proměnná Výstup Popis Verze
Rok
{{CURRENTYEAR}} 2024 Rok
Měsíc
{{CURRENTMONTH}} 03 Měsíc (dvojciferným číslem)
{{CURRENTMONTHNAME}} březen Měsíc (jménem)
{{CURRENTMONTHNAMEGEN}} března Měsíc (v genitivu)
{{CURRENTMONTHABBREV}} 3. Měsíc (pořadovým číslem) 1.5+
Den
{{CURRENTDAY}} 28 Den v měsíci (pořadovým číslem)
{{CURRENTDAY2}} 28 Den v měsíci (dvojciferným číslem) 1.6+
{{CURRENTDOW}} 4 Den v týdnu (unpadded number)
{{CURRENTDAYNAME}} čtvrtek Den v týdnu (jménem)
Čas
{{CURRENTTIME}} 08:49 Aktuální čas (24-hodinový tvar HH:mm )
{{CURRENTHOUR}} 08 Hodina (24-hodinový dvouciferný tvar)
Další
{{CURRENTWEEK}} 13 Týden (číslo)
{{CURRENTTIMESTAMP}} 20240328084940 ISO 8601 time stamp 1.7+

Následující proměnné dělají totéž co výše uvedené, ovšem výsledek je závislý na locales a ne uživatelském nastavení a UTC:

  • {{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.

Proměnná Výstup Popis Verze
Stránka
{{SITENAME}} DCEwiki Titulek wiki (Šablona:mediawiki).
{{CURRENTVERSION}} 1.39.2 Verze MediaWiki. 1.7+
{{CONTENTLANGUAGE}} cs Výchozí jazyk rozhraní (Šablona:mediawiki) 1.7+
Poslední revize aktuální stránky
{{REVISIONID}} 584 Unikátní ID revize 1.5+
{{REVISIONDAY}} 26 Den kdy byla provedena poslední úprava stránky (unpadded number) 1.8+
{{REVISIONDAY2}} 26 Den kdy byla provedena poslední úprava stránky (zero-padded number) 1.8+
{{REVISIONMONTH}} 08 Měsíc kdy byla provedena poslední úprava stránky (unpadded number) 1.8+
{{REVISIONYEAR}} 2008 Rok kdy byla provedena poslední úprava stránky 1.8+
{{REVISIONTIMESTAMP}} 20080826160521 Timestamp poslední úpravy stránky 1.8+

Statistika

Numbers returned by these variables contain number separators, but can return raw numbers with the ":R" flag (for example, {{NUMBEROFPAGES}} = 7 384 and {{NUMBEROFPAGES:R}} = 7384). Use "|R" for magic words that require a parameter like PAGESINCATEGORY (for example {{PAGESINCATEGORY:Help}} and {{PAGESINCATEGORY:Help|R}}).

Proměnná Výstup Popis Verze
Entire wiki
{{NUMBEROFPAGES}} 7 384 Počet stránek. 1.7+
{{NUMBEROFARTICLES}} 2 754 Počet stránek v hlavním jmenném prostoru.
{{NUMBEROFFILES}} 3 443 Počet natažených souborů. 1.5+
{{NUMBEROFEDITS}} 36 282 Number of page edits. Šablona:mediawiki
{{NUMBEROFUSERS}} 206 Počet registrovaných uživatelů. 1.7+
{{NUMBEROFADMINS}} 7 Počet členů skupiny sysop Šablona:mediawiki. 1.7+
Per namespace
{{PAGESINNS:2}}
{{PAGESINNAMESPACE:2}}
Šablona:PAGESINNS:2
Šablona:PAGESINNAMESPACE:2
Number of pages in the given namespace (replace 2 with the relevant namespace ID). Disabled by default, enable with Šablona:mediawiki. 1.7+
Other
{{PAGESINCATEGORY:Help}}
{{PAGESINCAT:Help}}
0
0
Number of pages in the given category (replace "Help" with the relevant category name). 1.13+
{{PAGESIZE:Help:Magic_words}} 0 Returns the byte size of the specified page. Šablona:mediawiki

URL data

URLs

Variable Output Description Versions
{{SERVER}} https://wiki.control.fel.cvut.cz domain URL (Šablona:mediawiki)
{{SERVERNAME}} wiki.control.fel.cvut.cz domain name (Šablona:mediawiki)
{{SCRIPTPATH}} /mediawiki relative script path (Šablona:mediawiki)
{{localurl:page name}}
{{localurl:page name|query string}}
/mediawiki/index.php/page_name
/mediawiki/index.php?title=page_name&query string
relative path to title
{{fullurl:page name}}
{{fullurl:page name|query_string}}
https://wiki.control.fel.cvut.cz/mediawiki/index.php/page_name
https://wiki.control.fel.cvut.cz/mediawiki/index.php?title=page_name&query_string
absolute path to title 1.5+
{{filepath:Wiki.png}} The absolute URL to a media file. Šablona:mediawiki
{{urlencode:x y z}} x+y+z The input encoded for use in URLs. Šablona:mediawiki
{{anchorencode:x y z}} x_y_z The input encoded for use in URL section anchors (after the '#' symbol in a URL). Šablona:mediawiki

Page names

Variable Output Description Versions
{{FULLPAGENAME}} Nápověda:Systémové proměnné a jejich použití Namespace and page title. 1.6+
{{PAGENAME}} Systémové proměnné a jejich použití Page title.
{{BASEPAGENAME}} Systémové proměnné a jejich použití Page title excluding the current subpage and namespace ("Title" on "Title/foo"). 1.7+
{{SUBPAGENAME}} Systémové proměnné a jejich použití The subpage title ("foo" on "Title/foo"). 1.6+
{{SUBJECTPAGENAME}} Nápověda:Systémové proměnné a jejich použití The namespace and title of the associated content page. 1.7+
{{TALKPAGENAME}} Diskuse k nápovědě:Systémové proměnné a jejich použití The namespace and title of the associated talk page. 1.7+

The following are URL-encoded equivalents:

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

Jmenné prostory

Proměnná Výstup Popis Verze
{{NAMESPACE}} Nápověda Namespace (name)
{{SUBJECTSPACE}}
{{ARTICLESPACE}}
Nápověda
Nápověda
Name of the associated content namespace 1.7+
{{TALKSPACE}} Diskuse k nápovědě Name of the associated talk namespace 1.7+

The following are URL-encoded equivalents:

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

{{ns:}} returns the localized namespace name for that number constant. The default values are:

Použití Výstup
{{ns:-2}} or {{ns:Media}} Média
{{ns:-1}} or {{ns:Special}} Speciální
{{ns:0}}
{{ns:1}} or {{ns:Talk}} Diskuse
{{ns:2}} or {{ns:User}} Uživatel
{{ns:3}} or {{ns:User_talk}} Diskuse s uživatelem
{{ns:4}} or {{ns:Project}} DCEwiki
{{ns:5}} or {{ns:Project_talk}} Diskuse k DCEwiki
{{ns:6}} or {{ns:Image}} Soubor
{{ns:7}} or {{ns:Image_talk}} Diskuse k souboru
{{ns:8}} or {{ns:MediaWiki}} MediaWiki
{{ns:9}} or {{ns:MediaWiki_talk}} Diskuse k MediaWiki
{{ns:10}} or {{ns:Template}} Šablona
{{ns:11}} or {{ns:Template_talk}} Diskuse k šabloně
{{ns:12}} or {{ns:Help}} Nápověda
{{ns:13}} or {{ns:Help_talk}} Diskuse k nápovědě
{{ns:14}} or {{ns:Category}} Kategorie
{{ns:15}} or {{ns:Category_talk}} Diskuse ke kategorii

Formátování

Použití Výstup Popis Verze
{{lc:XYZ}} xyz The lowercase input. 1.5+
{{lcfirst:XYZ}} xYZ The input with the first character lowercase. 1.5+
{{uc:xyz}} XYZ The uppercase input. 1.5+
{{ucfirst:xyz}} Xyz The input with the first character uppercase. 1.5+
{{formatnum:-987654321.654321}} −987 654 321,654321 The input with decimal and decimal group separators, and localized digit script, according to the wiki's default locale. 1.7+
{{padleft:xyz|5|_}}
{{padleft:xyz|5}}
__xyz
00xyz
The input (first parameter) padded on the left side to the specified width (second parameter) using the specified character (third parameter). If a padding character isn't specified, '0' is used by default.
bug: multibyte characters are interpreted as two characters, which can skew width. These also cannot be used as padding characters.
1.8+
{{padright:xyz|5|_}}
{{padright:xyz|5}}
xyz__
xyz00
Identical to padleft, but adds padding characters to the right side.
{{DIRMARK}}
{{DIRECTIONMARK}}

Outputs a unicode-directional mark that matches the wiki's default language's direction (‎ on left-to-right wikis, ‏ on right-to-left wikis), useful in text with multi-directional text. 1.7+
{{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".

Různé

Použití Výstup Popis Verze
{{#language:eo}} Esperanto The native name for the given language code. 1.7+
{{#special:userlogin}} Speciální:Přihlásit The localized name for the given canonical Special: page. Šablona:mediawiki
{{#tag:tagname}}
{{#tag:tagname|inner content|parameter=value|parameter2=value}}
(depends on parser tag) Alias for XML-style parser or extension tags, but parsing wiki code. Attribute values can be passed as parameter values ('<tagname attribute="value">' → '{{#tag:tagname|attribute=value}}'), and inner content as an unnamed parameter ('<tagname>content</tagname>' → '{{#tag:tagname|content}}'). 1.12+