ผลต่างระหว่างรุ่นของ "วิธีใช้:เมจิกเวิร์ด"

เนื้อหาที่ลบ เนื้อหาที่เพิ่ม
Horus (คุย | ส่วนร่วม)
Horus (คุย | ส่วนร่วม)
บรรทัด 234:
:{{sup|b}} วิกิพีเดียภาษาไทย
:{{sup|c}} แสดงผู้ใช้คนสุดท้ายที่แก้ไขหน้า ไม่มีทางใดแสดงผู้ใช้ที่เข้าชมหน้าเนื่องจากข้อจำกัดทางเทคนิค
 
==ฟังก์ชันตัวแจงส่วน==
{{Shortcut|WP:PF|WP:PARSER}}
{{anchor|PF}}
{{further|mw:Help:Magic words#Parser functions|mw:Help:Extension:ParserFunctions}}
 
===ข้อมูลอภิพันธุ์===
{| class="wikitable plainrowheaders"
! scope="col" | ฟังก์ชัน
! scope="col" | คำบรรยาย
|-
! scope="row" | <kbd>{<nowiki/>{PAGEID}}</kbd>
| เลขตัวระบุหน้าที่เป็นเอกลักษณ์
|-
! scope="row" | <kbd>{<nowiki/>{PAGESIZE:''fullpagename''}}</kbd>
| ขนาดของหน้าที่ระบุ หน่วยเป็นไบต์
|-
! scope="row" | {{anchor|PROTECTIONLEVEL}}<kbd>{<nowiki/>{PROTECTIONLEVEL:''action''{{pipe}}''fullpagename''}}</kbd>
| [[วิกิพีเดีย:นโยบายการล็อก|ระดับการล็อก]]ที่กำหนดต่อ "การกระทำ" ("แก้ไข", "ย้าย" ฯลฯ) ของหน้าที่ระบุ
|-
! scope="row" | {{anchor|PROTECTIONEXPIRY}}<kbd>{<nowiki/>{PROTECTIONEXPIRY:''action''{{pipe}}''fullpagename''}}</kbd>
| [[วิกิพีเดีย:นโยบายการล็อก|เวลาหมดอายุการล็อก]]ที่กำหนดต่อ "การกระทำ" ("แก้ไข", "ย้าย" ฯลฯ) ของหน้าที่ระบุ
<!-- |-
! scope="row" | <kbd>{<nowiki/>{PENDINGCHANGELEVEL}}</kbd>
| [[WP:PC|pending changes]] on the current page.
-->
|-
! scope="row" | <kbd>{<nowiki/>{PAGESINCATEGORY:''pagename''}}</kbd>
| จำนวนหน้าในหมวดหมู่ชื่อ ''pagename''
|-
! scope="row" | <kbd>{<nowiki/>{NUMBERINGROUP:''groupname''}}</kbd>
| จำนวนผู้ใช้ใน[[WP:UAL|กลุ่มผู้ใช้]]ชื่อ ''groupname''
|}
หากต้องการให้นำออกจำนวนโดยไม่มีอักขระคั่นจุลภาค (ตัวอย่างเช่น จะใช้ "123456789" แทน "123,456,789") ให้ผนวกตัวแปรเสริม <kbd>|R</kbd> ต่อท้ายโค้ด แต่อยู่ก่อนเครื่องหมายวงเล็บปีกกา
 
===การจัดรูปแบบ===
{| class="wikitable plainrowheaders"
! scope="col" | ฟังก์ชัน
! scope="col" | คำบรรยาย
|-
! scope="row" | <kbd> {{((}}lc:''string''{{))}} </kbd>
| เปลี่ยนอักขระทั้งหมดใน ''string'' เป็นตัวเล็ก
|-
! scope="row" | <kbd> {{((}}lcfirst:''string''{{))}} </kbd>
| เปลี่ยนอักขระตัวแรกใน ''string'' เป็นตัวเล็ก
|-
! scope="row" | <kbd> {{((}}uc:''string''{{))}} </kbd>
| เปลี่ยนอักขระทั้งหมดใน ''string'' เป็นตัวใหญ่
|-
! scope="row" | <kbd> {{((}}ucfirst:''string''{{))}} </kbd>
| เปลี่ยนอักขระตัวแรกใน ''string'' เป็นตัวเล็ก
|-
! scope="row" | <kbd> {{((}}formatnum:''unformatted_number''{{))}}<br>{{((}}formatnum:''formatted_num'' {{pipe}}R{{))}} </kbd>
| เพิ่มอักขระคั่นจุลภาคให้กับ ''unformatted_number'' (เช่น 123456789 จะกลายเป็น {{formatnum:123456789}}) หากต้องการลบการจัดรูปแบบดังกล่าว ให้ใช้ <kbd>{{((}}formatnum:''formatted_number''{{pipe}}R{{))}}</kbd> (ตัวอย่างเช่น <kbd>{{braces|formatnum:7,654,321{{pipe}}R}}</kbd> จะได้ {{formatnum:7,654,321|R}})
|-
! scope="row" | <kbd> {{((}}#dateformat:''date''{{pipe}}''format''{{))}}<br/>{{((}}#formatdate:''date''{{pipe}}''format''{{))}} </kbd>
| จัดรูปแบบวันที่ตามความพึงใจของผู้ใช้ สามารถระบุค่าโดยปริยายเป็นตัวแปรเสริมที่สองที่ไวต่ออักษรใหญ่เล็กได้โดยไม่ระบุวันเดือนปีที่พึงใจ (จะใส่หรือไม่ก็ได้) สามารถเปลี่ยนวันที่จากรูปแบบที่มีอยู่เป็น <code>dmy</code>, <code>mdy</code>, <code>ymd</code> หรือรูปแบบ <code>[[ISO 8601]]</code> ก็ได้ โดยค่าพึงใจของผู้ใช้จะเขียนทับรูปแบบที่เจาะจงไว้
|-
! scope="row" | <kbd> {{((}}padleft:''xyz''{{pipe}}''stringlength''{{))}} <br/> {{((}}padright:''xyz''{{pipe}}''stringlength''{{))}} <br><br> {{((}}padleft:''xyz''{{pipe}}''length''{{pipe}}''padstr''{{))}} <br/>{{((}}padright:''xyz''{{pipe}}''length''{{pipe}}''padstr''{{))}} </kbd>
| เพิ่มเลขศูนย์ '0' ต่อไปทางขวาหรือซ้ายจนมีจำนวนหลักตามที่กำหนด สามาระรุบสายอักขระเพิ่มทางเลือกเป็นตัวแปรเสริมที่ 3 สายอักขระเพิ่มซ้ำ (''padstr'') จะถูกตัดปลายหากความยาวของสายอักขระหารจำนวนอักขระที่ต้องการไม่ลงตัว
|-
! scope="row" | <kbd> {{((}}plural:''N''{{pipe}}''singular''{{pipe}}''plural''{{))}} </kbd>
| ให้ค่า ''singular'' ถ้า ''N'' เท่ากับ 1 ส่วนกรณีอื่นให้ค่า ''plural''
* ดูรายละเอียดเพิ่มที่ [[mw:Help:Magic words#Localization|documentation at mediawiki.org]]
|-
! scope="row" | <kbd> {{((}}#time:''format''{{pipe}}''object''{{))}} </kbd><br/> <kbd> {{((}}#timel:''format''{{pipe}}''object''{{))}} <br><br> {{((}}#time:d F Y{{pipe}}''date''{{pipe}}''langcode''{{))}} </kbd>
| Used to format dates and times, for ISO format, dots or English month names. <kbd>#timel</kbd> is based on local time as defined for each wiki; for English Wikipedia, this is identical to <kbd>#time</kbd>.<br />The optional 3rd parameter is the output language code (French, German, Swedish: fr, de, sv, etc.). Example Finnish: <kbd><nowiki>{{#time:d F Y|June 30, 2016|fi}}</nowiki></kbd> shows: {{#time:d F Y|June 30, 2016|fi}} (June). ISO to German: <kbd><nowiki>{{#time:d. M Y|1987-10-31|de}}</nowiki></kbd> shows: {{#time:d. M Y|1987-10-31|de}}.<br />For format codes, see: [[mw:Help:Extension:ParserFunctions##time]]. Use the format <kbd><nowiki>{{#time: H:i, j F Y (e)|...}}</nowiki></kbd> to match the format used by timestamps in signatures.
|-
! scope="row" | <kbd> {{((}}gender:''user''{{pipe}}''m_out''{{pipe}}''f_out''{{pipe}}''u_out''{{))}} </kbd>
| Outputs ''m_out'', ''f_out'' or ''u_out'' according to whether the gender specified in ''user''{{thinsp}}'s preferences is, respectively, male, female or unspecified. Other parameter permutations are available, see [[mw:Help:Magic words#gender]] and [[translatewiki:Special:MyLanguage/Gender|translatewiki:Gender]].
|-
! scope="row" | <kbd> [[mw:Help:Magic_words#Miscellaneous|{{((}}#tag:''tag''{{pipe}}''content with magic''{{))}} ]]</kbd>
| Only way to [[eval]]uate magic words ''inside a tag'', in order to generate <code>&lt;''tag''>''magic''&lt;/''tag''></code>. Also handles tag attributes.
|}
 
===Paths===
{| class="wikitable plainrowheaders"
! scope="col" | Function
! scope="col" | Description
|-
! scope="row" | <kbd> {{((}}localurl:''fullpagename'' {{pipe}}''query''{{))}} </kbd>
| Relative [[Path (computing)|path]] to page name. The ''query'' parameter is optional.
|-
! scope="row" | <kbd> {{((}}fullurl:''fullpagename'' {{pipe}}''query''{{))}} </kbd>
| Absolute path, without [[Application layer|protocol prefix]] (i.e. without "{{thinsp}}<nowiki>http:</nowiki>{{thinsp}}" etc.), to page name. The ''query'' parameter is optional.
|-
! scope="row" | <kbd> {{((}}canonicalurl:''fullpagename'' {{pipe}}''query''{{))}} </kbd>
| Absolute path, including protocol prefix, to page name. The ''query'' parameter is optional.
|-
! scope="row" | <kbd> {{((}}filepath:''filename''{{))}} </kbd>
| Absolute path to the media file ''filename''.
|-
! scope="row" | <kbd> {{((}}urlencode:''string''{{))}} </kbd>
| Encodes ''string'' for use in URL query strings; <kbd>{{braces|urlencode:test string}}</kbd>, for example, produces: {{urlencode:test string}}. To encode ''string'' for use in URL paths or MediaWiki page names, append, respectively, {{para||PATH}} or {{para||WIKI}} (to produce "{{urlencode:test string|PATH}}" or "{{urlencode:test string|WIKI}}").
|-
! scope="row" | <kbd> {{((}}anchorencode:''string''{{))}} </kbd>
| Input encoded for use in MediaWiki URL [[Help:Anchor|section anchor]]s.
|-
! scope="row" | <kbd> {{((}}ns:''n''{{))}} </kbd>
| Returns the name of the [[Help:Namespace|namespace]] whose index is the number ''n''. For MediaWiki URLs, use <kbd>{{((}}nse:{{))}}</kbd>.
|-
! scope="row" | <kbd>[[mw:Help:Extension:ParserFunctions##rel2abs|{{((}}#rel2abs:''path''{{))}}]] </kbd>
| Converts a relative file path to an absolute path.
|-
! scope="row" | <kbd> [[mw:Help:Extension:ParserFunctions##titleparts|{{((}}#titleparts:''fullpagename''{{pipe}}''number''{{pipe}}''first segment''{{))}}]]</kbd>
| Splits the fullpagename (title) into that number of segments.
|}
 
===Conditional===
{{further|Help:Conditional expressions}}
 
{| class="wikitable plainrowheaders"
! scope="col" | Function
! scope="col" | Description
|-
! scope="row" |<kbd> [[mw:Help:Extension:Parser functions##expr|{{((}}#expr:''expression''{{))}}]] </kbd>
| Evaluates ''expression'' (see [[m:Help:Calculation]]).
|-
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##if|{{((}}#if:''string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd>
| Outputs ''result2'' if ''string'' is [[Empty string|empty]], otherwise outputs ''result1''.
|-
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##ifeq|{{((}}#ifeq:''string1''{{pipe}}''string2'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd>
| Outputs ''result1'' if ''string1'' and ''string2'' are equal (alphabetically or numerically), otherwise outputs ''result2''.
|-
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##iferror|{{((}}#iferror:''test_string'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd>
| Outputs ''result1'' if ''test_string'' generates a parsing error, otherwise outputs ''result2''.
|-
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##ifexpr|{{((}}#ifexpr:''expression'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd>
| Outputs ''result1'' if ''expression''{{thinsp}} is true, otherwise outputs ''result2''.
|-
! scope="row" | <kbd> [[mw:Help:Extension:Parser functions##ifexist|{{((}}#ifexist:''pagetitle'' {{pipe}}''result1'' {{pipe}}''result2''{{))}}]] </kbd>
| Outputs ''result1'' if the page [<nowiki/>[''pagetitle'']] exists, otherwise outputs ''result2''. Note that underscores are needed for spaces in namespaces.
|-
! scope="row" style="white-space: nowrap;" | <kbd> [[mw:Help:Extension:Parser functions##switch|{{((}}#switch:''string'' {{pipe}}''c1''=''r1'' {{pipe}}''c2''=''r2'' ... {{pipe}}''default''{{))}}]] </kbd>
| Outputs ''r1'' if ''string'' is ''c1'', ''r2'' if ''string'' is ''c2'', etc., otherwise outputs ''default'' (if provided).
|}
 
If, in these conditional functions, [[Empty string|empty]] unnamed parameters are to be parsed as empty rather than as text (i.e. as empty rather than as the text "{{{1}}}", "{{{2}}}", etc.), they will require trailing pipes (i.e. <kbd>{{(((}}1{{pipe}}{{)))}}</kbd>, <kbd>{{(((}}2{{pipe}}{{)))}}</kbd>, etc., rather than <kbd>{{(((}}1{{)))}}</kbd>, <kbd>{{(((}}2{{)))}}</kbd>, etc.).
* For the use of these functions in tables, see [[Wikipedia:Conditional tables]].
 
===Other===
{| class="wikitable plainrowheaders"
! scope="col" | Function
! scope="col" | Description
|-
! scope="row" | <kbd>[[mw:Extension:Babel#Usage|{<nowiki/>{#babel:''code1''|''code2''|...}}]]</kbd>
| Render [[wp:userbox|userbox]]es telling your language skills. Improves upon {{tl|Babel}} (an alternative).
|-
! scope="row" | <kbd>[[mw:Extension:CategoryTree|{<nowiki/>{#categorytree:''category''|...}}]]</kbd>
| List pages in a category, recursively.
|-
! scope="row" | <kbd>[[mw:Extension:GeoData#Parser function|{<nowiki/>{#coordinates:''arg1''|''arg2''|...}}]]</kbd>
| Save the [[Geographic coordinate system|GeoData coordinates]] of the subject to the page's database. Used in {{tl|coord}}.
|-
! scope="row" style=white-space:nowrap| <kbd> [[mw:Extension:Scribunto#Usage|{<nowiki />{#invoke:''module''|''function''|''arg1''|...}}]]</kbd>
|| Use [[mw:extension:scribunto|Scribunto]] to transclude a [[wp:lua|lua]] template, e.g. function ''replace'' in [[Module:String#replace|module ''String'']].
|-
! scope="row" | <kbd>{<nowiki />{[[mw:Help:Magic_words#Miscellaneous|#language]]:[[ISO_639|''code1'']]|''code2''}}</kbd>
| Print the name represented by the language code, e.g. '''en''' → '''English'''. Print in language 2 if given.
|-
! scope="row" | <kbd>[[mw:Extension:Labeled Section Transclusion|<nowiki>{{#lst:}} {{#lsth:}} {{#lstx:}}</nowiki>]]</kbd>
| Three ways to [[Help:Labeled section transclusion|transclude a section of a page]].
|-
! scope="row" | <kbd>[[m:Wikidata/Notes/Inclusion syntax v0.4|{<nowiki />{#property:''arg1''|''arg2''|...}} ]]</kbd>
| Include a [[d:Help:FAQ#Terminology|property]] ([[wp:Wikidata|Wikidata]]) from a named entity, instead of the default on the page.
|-
! scope="row" | <kbd>[[mw:Reading/Web/Projects/Read more|{<nowiki />{#related:...}}]]</kbd>
| Links to similar topics, to engage readers. (Beta feature.)
|-
! scope="row" | <kbd>[[Help:Labeled section transclusion|{{#section<nowiki />:}}{{zwsp}}{{#section-h<nowiki />:}}{{zwsp}}{{#section-x<nowiki />:}}]]</kbd>
| Aliases for <kbd><nowiki>{{#lst:}} {{#lsth}} {{#lstx}}</nowiki></kbd> (above).
|-
! scope="row" | <kbd>[[mw:Help:Extension:MassMessage#Parser_function_delivery_lists|{<nowiki />{#target:''fullpagename''}}]]</kbd>
| Send a message to a list of talk pages on the fullpagename, using the [[m:MassMessage|MassMessage function]].
|-
! scope="row" | <kbd>[[mw:Help:Magic_words#Localization|{<nowiki />{int:''pagename''}}]] </kbd>
| [[Wikipedia:Transclusion|Transclude]] an ''interface'' message , i.e. a [[Special:PrefixIndex/MediaWiki:|pagename in MediaWiki namespace]]
|}