Bantuan:Kata ajaib: Perbedaan antara revisi

Konten dihapus Konten ditambahkan
Nurcilacap (bicara | kontrib)
Nurcilacap (bicara | kontrib)
Baris 63:
* <tt><nowiki>{{NUMBEROFPAGES}}, {{NUMBEROFARTICLES}}, {{NUMBEROFFILES}}, {{NUMBEROFEDITS}}, {{NUMBEROFVIEWS}}, {{NUMBEROFUSERS}}, {{NUMBEROFADMINS}}, {{NUMBEROFACTIVEUSERS}}</nowiki></tt> (statistics on English Wikipedia; add <tt>:R</tt> to return numbers without commas)
 
== Parser functions ==
==Fungsi==
{{Shortcut|WP:PF}}
===Metadata===
{{hatnote|For documentation, see the [[mw:Help:Magic words|MediaWiki magic words page]] or the [[mw:Help:Extension:ParserFunctions|ParserFunctions Extension page]], unless otherwise stated.}}
===Format===
 
===Pengalamatan===
===Ekspresi kondisionalMetadata bersyarat===
* <tt><nowiki>{{PAGEID}}</nowiki></tt> (unique page identifier number)
* <tt><nowiki>{{PAGESIZE:</nowiki>''page name''<nowiki>}}</nowiki></tt> (size of page in bytes)
* {{anchor|PROTECTIONLEVEL}}<tt><nowiki>{{PROTECTIONLEVEL:</nowiki>''action''<nowiki>|</nowiki>''pagename''<nowiki>}}</nowiki></tt> (protection level for given action on the specified page)
* <tt><nowiki>{{PENDINGCHANGELEVEL}}</nowiki></tt> (level of [[WP:PC|pending changes]] protection on the current page)
* <tt><nowiki>{{PAGESINCATEGORY:</nowiki>''categoryname''<nowiki>}}</nowiki></tt> (number of pages in the given [[Help:Categories|category]])
* <tt><nowiki>{{NUMBERINGROUP:</nowiki>''groupname''<nowiki>}}</nowiki></tt> (number of users in a specific [[Help:User rights|group]])
 
Add <tt>|R</tt> to return numbers without commas.
 
=== Formatting ===
* <tt><nowiki>{{lc:</nowiki>''string''<nowiki>}}</nowiki></tt> (convert to lower case)
* <tt><nowiki>{{lcfirst:</nowiki>''string''<nowiki>}}</nowiki></tt> (convert first character to lower case)
* <tt><nowiki>{{uc:</nowiki>''string''<nowiki>}}</nowiki></tt> (convert to upper case)
* <tt><nowiki>{{ucfirst:</nowiki>''string''<nowiki>}}</nowiki></tt> (convert first character to upper case)
* <tt><nowiki>{{formatnum:</nowiki>''unformatted&nbsp;num''<nowiki>}}</nowiki></tt> (format a number with comma separators; add <tt><nowiki>|</nowiki>R</tt> to unformat a number)
* <tt><nowiki>{{#formatdate:</nowiki>''date''|''format''<nowiki>}}</nowiki></tt> (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 <tt>dmy</tt>, <tt>mdy</tt>, <tt>ymd</tt> or <tt>ISO 8601</tt> formats, with the user's preference overriding the specified format)
* <tt><nowiki>{{padleft:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></tt>, <tt><nowiki>{{padright:xyz|</nowiki>''stringlength''<nowiki>}}</nowiki></tt> (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)
* <tt><nowiki>{{plural:</nowiki>''n''|''is''<nowiki>|</nowiki>''are''<nowiki>}}</nowiki></tt> (produces alternative text according to whether ''n'' is greater than 1)
* <tt><nowiki>{{#time:</nowiki>''format string''|''date/time object''<nowiki>}}</nowiki></tt> (for date/time formatting; also <tt>#timel</tt> for local time. Covered at the [[mw:Help:Extension:ParserFunctions##time|extension documentation page]].)
* <tt><nowiki>{{gender:</nowiki>''username''|''masculine''|''feminine''|''neutral''}}</tt> (produces alternative text according to the gender specified by the given user in his/her preferences)
* <tt><nowiki>{{#tag:</nowiki>''tagname''|''content''|''parameter1''=''value1''|''parameter2''=''value2''}}</tt> (equivalent to an HTML tag or pair of tags; can be used for [[WP:REFNEST|nesting references]])
 
===Metadata Paths ===
* <tt><nowiki>{{localurl:</nowiki>''page name''<nowiki>}}</nowiki></tt>, <tt><nowiki>{{localurl:</nowiki>''page name''<nowiki>|</nowiki>''query string''<nowiki>}}</nowiki></tt> (relative path to the title)
* <tt><nowiki>{{fullurl:</nowiki>''page name''<nowiki>}}</nowiki></tt>, <tt><nowiki>{{fullurl:</nowiki>''page name''<nowiki>|</nowiki>''query_string''<nowiki>}}</nowiki></tt> (absolute path to the title, without a protocol prefix)
* <tt><nowiki>{{canonicalurl:</nowiki>''page name''<nowiki>}}</nowiki></tt>, <tt><nowiki>{{canonicalurl:</nowiki>''page name''<nowiki>|</nowiki>''query_string''<nowiki>}}</nowiki></tt> (absolute path to the title, with a protocol prefix)
* <tt><nowiki>{{filepath:</nowiki>''file name''<nowiki>}}</nowiki></tt> (absolute URL to a media file)
* <tt><nowiki>{{urlencode:</nowiki>''string''<nowiki>}}</nowiki></tt> (input encoded for use in URL query strings: {{urlencode:like this}})
** <tt><nowiki>{{urlencode:</nowiki>''string''<nowiki>|PATH}}</nowiki></tt> (input encoded for use in URL paths: {{urlencode:like this|PATH}})
** <tt><nowiki>{{urlencode:</nowiki>''string''<nowiki>|WIKI}}</nowiki></tt> (input encoded for use as MediaWiki page names: {{urlencode:like this|WIKI}})
* <tt><nowiki>{{anchorencode:</nowiki>''string''<nowiki>}}</nowiki></tt> (input encoded for use in MediaWiki URL section anchors)
* <tt><nowiki>{{ns:</nowiki>''n''<nowiki>}}</nowiki></tt> (name for the [[Help:Namespace|namespace]] with index ''n''; use <tt><nowiki>{{nse:}}</nowiki></tt> for the equivalent encoded for MediaWiki URLs)
* <tt><nowiki>{{#rel2abs:</nowiki> ''path'' <nowiki>}}</nowiki></tt> (converts a relative file path to absolute; see the [[mw:Help:Extension:ParserFunctions|extension documentation]])
* <tt><nowiki>{{#titleparts:</nowiki> ''pagename'' | ''number of segments to return'' | ''first segment to return'' <nowiki>}}</nowiki></tt> (splits title into parts; see the [[mw:Help:Extension:ParserFunctions|extension documentation]])
 
=== Conditional expressions ===
{{hatnote|For documentation, see the [[mw:Help:Extension:ParserFunctions|ParserFunctions Extension page]]. Note that some parameters are optional.}}
* <tt><nowiki>{{#expr:</nowiki> ''expression'' <nowiki>}}</nowiki></tt> (evaluates the given expression; see [[Help:Calculation]])
* <tt><nowiki>{{#if:</nowiki> ''test string'' | ''value if non-empty'' | ''value if empty'' <nowiki>}}</nowiki></tt> (selects one of two values based on whether the test string is empty)
* <tt><nowiki>{{#ifeq:</nowiki> ''string 1'' <nowiki>|</nowiki> ''string 2'' <nowiki>|</nowiki> ''value if equal'' <nowiki>|</nowiki> ''value if unequal'' <nowiki>}}</nowiki></tt> (selects one of two values based on whether the test strings are equal – numerically if applicable)
* <tt><nowiki>{{#iferror:</nowiki> ''test string'' <nowiki>|</nowiki> ''value if error'' <nowiki>|</nowiki> ''value if correct'' <nowiki>}}</nowiki></tt> (selects value based on whether the test string generates a parser error)
* <tt><nowiki>{{#ifexpr:</nowiki> ''expression'' <nowiki>|</nowiki> ''value if true'' <nowiki>|</nowiki> ''value if false'' <nowiki>}}</nowiki></tt> (selects value based on evaluation of expression)
* <tt><nowiki>{{#ifexist:</nowiki> ''page title'' | ''value if exists'' | ''value if doesn't exist'' <nowiki>}}</nowiki></tt> (selects value depending on whether a page title exists)
* <tt><nowiki>{{#switch:</nowiki> ''test'' | ''case1'' = ''value for case 1'' | ... | ''default'' <nowiki>}}</nowiki></tt> (provides alternatives based on the value of the test string)
 
Note that with <code>#if:</code> expressions, a variable like <code><nowiki>{{{1}}}</nowiki></code> always requires a final pipe: <code><nowiki>{{{1|}}}</nowiki></code>. If it is absent, then whenever the parameter 1 is absent, instead of leaving the field blank the software will use the actual text ''<code>{{{1}}}</code>'' and the field will never be empty.
 
For the use of these functions in tables, see [[Wikipedia:Conditional tables|WP:Conditional tables]].
 
For examples and more explanation, see [[Help:Conditional expressions]] and [[Help:Switch parser function]].
 
===Format Other ===
* <code><nowiki>{{#babel:</nowiki> ''babelcode1'' | ''babelcode2'' | ... <nowiki>}}</nowiki></code> (replacement for the {{tlx|babel}} template; see [[mw:Extension:Babel#Usage|Extension:Babel]])
* <code><nowiki>{{#coordinates:</nowiki> ''arg1'' | ''arg2'' | ... <nowiki>}}</nowiki></code> (see [[mw:Extension:GeoData|Extension:GeoData]])
* <code><nowiki>{{#invoke:</nowiki> ''module'' | ''function'' | ''arg1'' | ''arg2'' | ... <nowiki>}}</nowiki></code> (calls a function located in a Scribunto module; see [[Wikipedia:Lua]])
* <code><nowiki>{{#language:</nowiki> ''code1'' | ''code2'' <nowiki>}}</nowiki></code> (converts a language code into a language name; see [[mw:Help:Magic words#Miscellaneous]])
** <code><nowiki>{{#language:ar}}</nowiki></code> → {{#language:ar}}
** <code><nowiki>{{#language:ar|en}}</nowiki></code> → {{#language:ar|en}}
** <code><nowiki>{{#language:ar|fr}}</nowiki></code> → {{#language:ar|fr}}
* <code><nowiki>{{#property:</nowiki> ''arg1'' | ''arg2'' | ... <nowiki>}}</nowiki></code> (see [[m:Wikidata/Notes/Inclusion syntax v0.3]])
 
== See also ==
* [[mw:Localisation]]