Bantuan:Kata ajaib

Revisi sejak 29 Januari 2017 08.52 oleh HsfBot (bicara | kontrib) (Bot: Perubahan kosmetika)

Kata ajaib adalah fitur dari wikitext yang memungkinkan berbagai instruksi untuk diberikan ke perangkat lunak MediaWiki, misalkan untuk menampilkan variabel yang sering digunakan dalam menulis artikel atau dalam templat.

Informasi umum

Jenis-jenis

Beberapa jenis kata ajaib adalah:

  1. Behavior switches atau perubahan: Kata ajaib jenis ini berbentuk sebuah kata yang ditulis menggunakan huruf kapital dan dikelilingi oleh 2 (dua) garis bawah (undercsore), contoh __NOTDOC__
  2. Variables atau variabel: Kata ajaib jenis ini berbentuk sebuah kata yang ditulis menggunakan huruf kapital dan dikelilingi oleh 2 (dua) tanda kurung kurawal sehingga terlihat seperti templat, contoh {{PAGENAME}}
  3. Parser functions atau fungsi parser:Kata ajaib jenis ini berbentuk sebuah kata yang dikelilingi oleh 2 (dua) tanda kurung kurawal dan diawali dengan tanda pagar (#), contoh {{#expr:2+2}}

Beberapa kata ajaib adalah case-insensitive, tetapi tidak semuanya. Ruang putih dilucuti dari awal dan kata kunci akhir dan parameter, seperti dalam sintaks templat.

Halaman yang tergantung kata-kata ajaib akan mempengaruhi atau mengembalikan data tentang halaman ini, even if the word is added through a transcluded template or included system message.

Perubahan

  • __NOTOC__ (dapat muncul di mana saja di Wikitext tersebut; menekan daftar isi)
  • __FORCETOC__ (dapat muncul di mana saja di Wikitext tersebut; membuat daftar isi muncul dalam posisi normal di atas judul pertama)
  • __TOC__ (menempatkan daftar isi pada posisi kata itu)
  • __NOEDITSECTION__ (menyembunyikan bagian "edit" link di samping semua judul atau header pada halaman) (gunakan tag <h2> untuk menyembunyikan link edit untuk satu pos saja)
  • __NEWSECTIONLINK__ (menambahkan link "+" untuk menambahkan bagian baru pada halaman yang bukan-"Pembicaraan")
  • __NONEWSECTIONLINK__ (menghapus link "+" pada halaman "Pembicaraan" )
  • __NOGALLERY__ (pada halaman kategori, menggantikan thumbnail dengan link normal)
  • __HIDDENCAT__ (pada halaman kategori, membuatnya menjadi hidden category)
  • __INDEX__ (memberitahu mesin pencari untuk mengindeks halaman)
  • __NOINDEX__ (memberitahu search engine tidak mengindeks halaman)
  • __STATICREDIRECT__ (Pada halaman redirect, jangan biarkan MediaWiki untuk secara otomatis memperbarui link ketika seseorang bergerak halaman dan cek "Update setiap pengalihan yang mengarah ke judul asli"​​, juga digunakan untuk memberitahu interwikibots bahwa redirect ini dapat dilihat sebagai sebuah artikel)
  • __DISAMBIG__ (menandai halaman sebagai disambiguation page dan menempatkannya di Istimewa:DisambiguationPages, dan tempat-tempat ke dalam link di Istimewa:DisambiguationPageLinks). Nah mw:Extension:Disambiguator.
  • {{DISPLAYTITLE:title}} (ganti displayed form dari judul halaman)
  • {{DEFAULTSORT:sortkey}} (sets a default category sort key)
  • {{noexternallanglinks}} untuk menekan semua Wikidata otomatis Link antar bahasa. Setara dengan {{noexternallanglinks:*}}. Link untuk bahasa individu dapat ditekan dengan menentukan kode bahasa dalam daftar pipa-dipisahkan, misalnya {{noexternallanglinks:fr|es|ja}}. Nah lihat mw:Extension:Wikibase Client#noexternallanglinks.

Variabel

  • {{ARTICLEPAGENAME}} (associated non-talk page) (identical to {{SUBJECTPAGENAME}} )
  • {{ARTICLESPACE}} (associated non-talk namespace) (identical to {{SUBJECTSPACE}} )
  • {{BASEPAGENAME}} (page title excluding current subpage and namespace - effectively the parent page without the namespace)
  • {{FULLPAGENAME}} (page title including namespace)
  • {{NAMESPACE}} (namespace of current page)
  • {{PAGENAME}} (page title excluding namespace)
  • {{SUBJECTPAGENAME}} (associated non-talk page) (identical to {{ARTICLEPAGENAME}} )
  • {{SUBJECTSPACE}} (associated non-talk namespace) (identical to {{ARTICLESPACE}} )
  • {{SUBPAGENAME}} (subpage part of title)
  • {{TALKPAGENAME}} (associated talk page)
  • {{TALKSPACE}} (associated talk namespace)
  • {{FULLPAGENAMEE}}, {{NAMESPACEE}} etc. (equivalents encoded for use in MediaWiki URLs)

Catatan: semua variabel sebelumnya masing-masing dapat mengambil parameter, untuk beroperasi pada halaman selain halaman saat ini. misalnya{{TALKPAGENAME:WP:MOS}} kembali ke "Pembicaraan Wikipedia:MOS".

  • {{SITENAME}} (Wikipedia)
  • {{SERVER}} (//wiki-indonesia.club)
  • {{SERVERNAME}} (wiki-indonesia.club)
  • {{SCRIPTPATH}} (/w)
  • {{CURRENTVERSION}} (current MediaWiki version)
  • {{REVISIONID}} (revisi terbaru untuk saat ini halaman-itu tidak dapat diganti dan juga tidak bekerja di pratinjau)
  • {{REVISIONDAY}}, {{REVISIONDAY2}}, {{REVISIONMONTH}}, {{REVISIONYEAR}}, {{REVISIONTIMESTAMP}}, {{REVISIONUSER}} (date, time, editor at last edit)
  • {{CURRENTYEAR}}, {{CURRENTMONTH}}, {{CURRENTMONTHNAME}}, {{CURRENTMONTHABBREV}}, {{CURRENTDAY}}, {{CURRENTDAY2}}, {{CURRENTDOW}}, {{CURRENTDAYNAME}}, {{CURRENTTIME}}, {{CURRENTHOUR}}, {{CURRENTWEEK}}, {{CURRENTTIMESTAMP}} (current date/time variables)
  • {{LOCALYEAR}} etc. (as previously, based on site's local time)
  • {{NUMBEROFPAGES}}, {{NUMBEROFARTICLES}}, {{NUMBEROFFILES}}, {{NUMBEROFEDITS}}, {{NUMBEROFVIEWS}}, {{NUMBEROFUSERS}}, {{NUMBEROFADMINS}}, {{NUMBEROFACTIVEUSERS}} (statistics on English Wikipedia; add :R to return numbers without commas)

Parser functions

Metadata

  • {{PAGEID}} (unique page identifier number)
  • {{PAGESIZE:page name}} (size of page in bytes)
  • {{PROTECTIONLEVEL:action|pagename}} (protection level for given action on the specified page)
  • {{PENDINGCHANGELEVEL}} (level of pending changes protection on the current page)
  • {{PAGESINCATEGORY:categoryname}} (number of pages in the given category)
  • {{NUMBERINGROUP:groupname}} (number of users in a specific group)

Add |R to return numbers without commas.

Formatting

  • {{lc:string}} (convert to lower case)
  • {{lcfirst:string}} (convert first character to lower case)
  • {{uc:string}} (convert to upper case)
  • {{ucfirst:string}} (convert first character to upper case)
  • {{formatnum:unformatted num}} (format a number with comma separators; add |R to unformat a number)
  • {{#formatdate:date|format}} (formats a date according to user preferences; a default can be given as an optional case-sensitive second parameter for users without date preference; can convert a date from an existing format to any of dmy, mdy, ymd or ISO 8601 formats, with the user's preference overriding the specified format)
  • {{padleft:xyz|stringlength}}, {{padright:xyz|stringlength}} (pad with zeros to the right or left; an alternative padding string can be given as a third parameter; the alternative padding string may be truncated if its length does not evenly divide the required number of characters)
  • {{plural:n|is|are}} (produces alternative text according to whether n is greater than 1)
  • {{#time:format string|date/time object}} (for date/time formatting; also #timel for local time. Covered at the extension documentation page.)
  • {{gender:username|masculine|feminine|neutral}} (produces alternative text according to the gender specified by the given user in his/her preferences)
  • {{#tag:tagname|content|parameter1=value1|parameter2=value2}} (equivalent to an HTML tag or pair of tags; can be used for nesting references)

Paths

  • {{localurl:page name}}, {{localurl:page name|query string}} (relative path to the title)
  • {{fullurl:page name}}, {{fullurl:page name|query_string}} (absolute path to the title, without a protocol prefix)
  • {{canonicalurl:page name}}, {{canonicalurl:page name|query_string}} (absolute path to the title, with a protocol prefix)
  • {{filepath:file name}} (absolute URL to a media file)
  • {{urlencode:string}} (input encoded for use in URL query strings: like+this)
    • {{urlencode:string|PATH}} (input encoded for use in URL paths: like%20this)
    • {{urlencode:string|WIKI}} (input encoded for use as MediaWiki page names: like_this)
  • {{anchorencode:string}} (input encoded for use in MediaWiki URL section anchors)
  • {{ns:n}} (name for the namespace with index n; use {{nse:}} for the equivalent encoded for MediaWiki URLs)
  • {{#rel2abs: path }} (converts a relative file path to absolute; see the extension documentation)
  • {{#titleparts: pagename | number of segments to return | first segment to return }} (splits title into parts; see the extension documentation)

Conditional expressions

  • {{#expr: expression }} (evaluates the given expression; see Bantuan:Calculation)
  • {{#if: test string | value if non-empty | value if empty }} (selects one of two values based on whether the test string is empty)
  • {{#ifeq: string 1 | string 2 | value if equal | value if unequal }} (selects one of two values based on whether the test strings are equal – numerically if applicable)
  • {{#iferror: test string | value if error | value if correct }} (selects value based on whether the test string generates a parser error)
  • {{#ifexpr: expression | value if true | value if false }} (selects value based on evaluation of expression)
  • {{#ifexist: page title | value if exists | value if doesn't exist }} (selects value depending on whether a page title exists)
  • {{#switch: test | case1 = value for case 1 | ... | default }} (provides alternatives based on the value of the test string)

Note that with #if: expressions, a variable like {{{1}}} always requires a final pipe: {{{1|}}}. If it is absent, then whenever the parameter 1 is absent, instead of leaving the field blank the software will use the actual text {{{1}}} and the field will never be empty.

For the use of these functions in tables, see WP:Conditional tables.

For examples and more explanation, see Bantuan:Conditional expressions and Bantuan:Switch parser function.

Other

Lihat pula