|
|
Line 1: |
Line 1: |
| <table style="background:transparent"><tr>
| | {{Help contents back}} |
| <td> [[Help:Contents|<img alt="" src="/code/images/thumb/8/8e/1leftarrow.png/16px-1leftarrow.png" width="16" height="16" border="0">]]
| | '''Magic words''' (which include '''parser functions''', '''variables''' and '''behavior switches''') are features of wikitext that enable various instructions to be given to the MediaWiki software (for example, to suppress or position the table of contents), or else serve to produce variable output, as is often required in templates. |
| </td>
| |
| <td> <big>[[Help:Contents]]</big>
| |
| </td>
| |
| </tr></table>'''Magic words''' (which include '''parser functions''', '''variables''' and '''behavior switches''') are features of wikitext that enable various instructions to be given to the MediaWiki software (for example, to suppress or position the table of contents), or else serve to produce variable output, as is often required in templates.
| |
|
| |
|
|
| |
|
Line 12: |
Line 8: |
|
| |
|
|
| |
|
| * '''Behavior switches:''' uppercase words surrounded by double underscores, e.g. <tt>__NOTOC__</tt>, or keywords using parser function syntax | | * '''Behavior switches:''' uppercase words surrounded by double underscores, e.g. <nowiki>__NOTOC__</nowiki>, or keywords using parser function syntax |
| * '''Variables:''' uppercase words surrounded by double braces, e.g. <tt>{{PAGENAME}}</tt> (thus resembling [[Help:Templates|templates]]) | | * '''Variables:''' uppercase words surrounded by double braces, e.g. <nowiki>{{PAGENAME}}</nowiki> (thus resembling [[Help:Templates|templates]]) |
| * '''Parser functions:''' keywords (some beginning #) in double braces with parameters after a colon, e.g. <tt>{{#expr:2+2}}</tt> | | * '''Parser functions:''' keywords (some beginning #) in double braces with parameters after a colon, e.g. <nowiki>{{#expr:2+2}}</nowiki> |
| Some magic words are case-insensitive, but not all. Whitespace is stripped from the start and end of keywords and parameters, as in '''template''' syntax. | | Some magic words are case-insensitive, but not all. Whitespace is stripped from the start and end of keywords and parameters, as in '''template''' syntax. |
|
| |
|
Line 25: |
Line 21: |
|
| |
|
|
| |
|
| * <tt>__NOTOC__</tt> (can appear anywhere in the wikitext; suppresses the table of contents) | | * <nowiki>__NOTOC__</nowiki> (can appear anywhere in the wikitext; suppresses the table of contents) |
| * <tt>__FORCETOC__</tt> (can appear anywhere in the wikitext; makes a table of contents appear in its normal position above the first header) | | * <nowiki>__FORCETOC__</nowiki> (can appear anywhere in the wikitext; makes a table of contents appear in its normal position above the first header) |
| * <tt>__TOC__</tt> (places a table of contents at the word's position) | | * <nowiki>__TOC__</nowiki> (places a table of contents at the word's position) |
| * <tt>__NOEDITSECTION__</tt> (hides the section edit links beside headings) | | * <nowiki>__NOEDITSECTION__</nowiki> (hides the section edit links beside headings) |
| * <tt>__NEWSECTIONLINK__</tt> (adds a "+" link for adding a new section on a non-"Talk" page) | | * <nowiki>__NEWSECTIONLINK__</nowiki> (adds a "+" link for adding a new section on a non-"Talk" page) |
| * <tt>__NONEWSECTIONLINK__</tt> (removes the "+" link on "Talk" pages) | | * <nowiki>__NONEWSECTIONLINK__</nowiki> (removes the "+" link on "Talk" pages) |
| * <tt>__NOGALLERY__</tt> (on a category page, replaces thumbnails with normal links) | | * <nowiki>__NOGALLERY__</nowiki> (on a category page, replaces thumbnails with normal links) |
| * <tt>__HIDDENCAT__</tt> (on a category page, makes it a hidden category) | | * <nowiki>__HIDDENCAT__</nowiki> (on a category page, makes it a hidden category) |
| * <tt>__INDEX__</tt> (tells search engines to index the page) | | * <nowiki>__INDEX__</nowiki> (tells search engines to index the page) |
| * <tt>__NOINDEX__</tt> (tells search engines not to index the page) | | * <nowiki>__NOINDEX__</nowiki> (tells search engines not to index the page) |
| * <tt>{{DISPLAYTITLE:''title''}}</tt> (changes the displayed form of the page title) | | * <nowiki>{{DISPLAYTITLE:''title''}}</nowiki> (changes the displayed form of the page title) |
| * <tt>{{DEFAULTSORT:''sortkey''}}</tt> (sets a default category sort key) | | * <nowiki>{{DEFAULTSORT:''sortkey''}}</nowiki> (sets a default category sort key) |
|
| |
|
| == Variables == | | == Variables == |
Line 42: |
Line 38: |
|
| |
|
|
| |
|
| * <tt>{{FULLPAGENAME}}</tt> (page title including namespace) | | * <nowiki>{{FULLPAGENAME}}</nowiki> (page title including namespace) |
| * <tt>{{PAGENAME}}</tt> (page title excluding namespace) | | * <nowiki>{{PAGENAME}}</nowiki> (page title excluding namespace) |
| * <tt>{{BASEPAGENAME}}</tt> (page title excluding subpage and namespace) | | * <nowiki>{{BASEPAGENAME}}</nowiki> (page title excluding subpage and namespace) |
| * <tt>{{SUBPAGENAME}}</tt> (subpage part of title) | | * <nowiki>{{SUBPAGENAME}}</nowiki> (subpage part of title) |
| * <tt>{{SUBJECTPAGENAME}}</tt> (associated non-talk page) | | * <nowiki>{{SUBJECTPAGENAME}}</nowiki> (associated non-talk page) |
| * <tt>{{TALKPAGENAME}}</tt> (associated talk page) | | * <nowiki>{{TALKPAGENAME}}</nowiki> (associated talk page) |
| * <tt>{{NAMESPACE}}</tt> (namespace of current page) | | * <nowiki>{{NAMESPACE}}</nowiki> (namespace of current page) |
| * <tt>{{SUBJECTSPACE}}, {{ARTICLESPACE}}</tt> (associated non-talk namespace) | | * <nowiki>{{SUBJECTSPACE}}, {{ARTICLESPACE}}</nowiki> (associated non-talk namespace) |
| * <tt>{{TALKSPACE}}</tt> (associated talk namespace) | | * <nowiki>{{TALKSPACE}}</nowiki> (associated talk namespace) |
| * <tt>{{FULLPAGENAMEE}}, {{NAMESPACEE}}</tt> etc. (URL-encoded equivalents) | | * <nowiki>{{FULLPAGENAMEE}}, {{NAMESPACEE}}</nowiki> etc. (URL-encoded equivalents) |
| The above can all take a parameter, to operate on a page other than the current page. | | The above can all take a parameter, to operate on a page other than the current page. |
|
| |
|
|
| |
|
| * <tt>{{SITENAME}}</tt> (Wikipedia of the Dark Jedi Brotherhood, an online Star Wars Club) | | * <nowiki>{{SITENAME}}</nowiki> (Wikipedia of the Dark Jedi Brotherhood, an online Star Wars Club) |
| * <tt>{{SERVER}}</tt> (http://en.wikipedia.org) | | * <nowiki>{{SERVER}}</nowiki> (http://en.wikipedia.org) |
| * <tt>{{SERVERNAME}}</tt> (wiki.darkjedibrotherhood.com) | | * <nowiki>{{SERVERNAME}}</nowiki> (wiki.darkjedibrotherhood.com) |
| * <tt>{{SCRIPTPATH}}</tt> (/code) | | * <nowiki>{{SCRIPTPATH}}</nowiki> (/code) |
| * <tt>{{CURRENTVERSION}}</tt> (current MediaWiki version) | | * <nowiki>{{CURRENTVERSION}}</nowiki> (current MediaWiki version) |
| * <tt>{{REVISIONID}}</tt> (latest revision to current page) | | * <nowiki>{{REVISIONID}}</nowiki> (latest revision to current page) |
| * <tt>{{REVISIONDAY}}, {{REVISIONDAY2}}, {{REVISIONMONTH}}, {{REVISIONYEAR}}, {{REVISIONTIMESTAMP}}, {{REVISIONUSER}}</tt> (date, time, editor at last edit) | | * <nowiki>{{REVISIONDAY}}, {{REVISIONDAY2}}, {{REVISIONMONTH}}, {{REVISIONYEAR}}, {{REVISIONTIMESTAMP}}, {{REVISIONUSER}}</nowiki> (date, time, editor at last edit) |
| * <tt>{{CURRENTYEAR}}, {{CURRENTMONTH}}, {{CURRENTMONTHNAME}}, {{CURRENTMONTHABBREV}}, {{CURRENTDAY}}, {{CURRENTDAY2}}, {{CURRENTDOW}}, {{CURRENTDAYNAME}}, {{CURRENTTIME}}, {{CURRENTHOUR}}, {{CURRENTWEEK}}, {{CURRENTTIMESTAMP}}</tt> (current date/time variables) | | * <nowiki>{{CURRENTYEAR}}, {{CURRENTMONTH}}, {{CURRENTMONTHNAME}}, {{CURRENTMONTHABBREV}}, {{CURRENTDAY}}, {{CURRENTDAY2}}, {{CURRENTDOW}}, {{CURRENTDAYNAME}}, {{CURRENTTIME}}, {{CURRENTHOUR}}, {{CURRENTWEEK}}, {{CURRENTTIMESTAMP}}</nowiki> (current date/time variables) |
| * <tt>{{LOCALYEAR}}</tt> etc. (as above, based on site's local time) | | * <nowiki>{{LOCALYEAR}}</nowiki> etc. (as above, based on site's local time) |
| * <tt>{{NUMBEROFPAGES}}, {{NUMBEROFARTICLES}}, {{NUMBEROFFILES}}, {{NUMBEROFEDITS}}, {{NUMBEROFVIEWS}}, {{NUMBEROFUSERS}}, {{NUMBEROFADMINS}}, {{NUMBEROFACTIVEUSERS}}</tt> (statistics on English Wikipedia; add <tt>:R</tt> to return numbers without commas) | | * <nowiki>{{NUMBEROFPAGES}}, {{NUMBEROFARTICLES}}, {{NUMBEROFFILES}}, {{NUMBEROFEDITS}}, {{NUMBEROFVIEWS}}, {{NUMBEROFUSERS}}, {{NUMBEROFADMINS}}, {{NUMBEROFACTIVEUSERS}}</nowiki> (statistics on English Wikipedia; add <nowiki>:R</nowiki> to return numbers without commas) |
|
| |
|
| == Parser functions == | | == Parser functions == |
Line 72: |
Line 68: |
|
| |
|
| === Metadata === | | === Metadata === |
| * <tt>{{PAGESIZE:''page name''}}</tt> (size of page in bytes) | | * <nowiki>{{PAGESIZE:''page name''}}</nowiki> (size of page in bytes) |
| * <tt>{{PROTECTIONLEVEL:''action''}}</tt> (protection level for given action on the current page) | | * <nowiki>{{PROTECTIONLEVEL:''action''}}</nowiki> (protection level for given action on the current page) |
| * <tt>{{PAGESINCATEGORY:''categoryname''}}</tt> (number of pages in the given [[Help:Category|category]]) | | * <nowiki>{{PAGESINCATEGORY:''categoryname''}}</nowiki> (number of pages in the given [[Help:Category|category]]) |
| * <tt>{{NUMBERINGROUP:''groupname''}}</tt> (number of users in a specific group) | | * <nowiki>{{NUMBERINGROUP:''groupname''}}</nowiki> (number of users in a specific group) |
| Add <tt>|R</tt> to return numbers without commas. | | Add <nowiki>|R</nowiki> to return numbers without commas. |
|
| |
|
|
| |
|
|
| |
|
| === Formatting === | | === Formatting === |
| * <tt>{{lc:''string''}}</tt> (convert to lower case) | | * <nowiki>{{lc:''string''}}</nowiki> (convert to lower case) |
| * <tt>{{lcfirst:''string''}}</tt> (convert first character to lower case) | | * <nowiki>{{lcfirst:''string''}}</nowiki> (convert first character to lower case) |
| * <tt>{{uc:''string''}}</tt> (convert to upper case) | | * <nowiki>{{uc:''string''}}</nowiki> (convert to upper case) |
| * <tt>{{ucfirst:''string''}}</tt> (convert first character to upper case) | | * <nowiki>{{ucfirst:''string''}}</nowiki> (convert first character to upper case) |
| * <tt>{{formatnum:''unformatted num''}}</tt> (format a number with comma separators; add <tt>|R</tt> to unformat a number) | | * <nowiki>{{formatnum:''unformatted num''}}</nowiki> (format a number with comma separators; add <nowiki>|R</nowiki> to unformat a number) |
| * <tt>{{#formatdate:''date''}}</tt> (formats a date according to user preferences; a default can be given as a second parameter for users without date preference). | | * <nowiki>{{#formatdate:''date''}}</nowiki> (formats a date according to user preferences; a default can be given as a second parameter for users without date preference). |
| * <tt>{{padleft:xyz|''stringlength''}}</tt>, <tt>{{padright:xyz|''stringlength''}}</tt> (pad with zeros to the right or left; an alternative padding string can be given as a third parameter) | | * <nowiki>{{padleft:xyz|''stringlength''}}</nowiki>, <nowiki>{{padright:xyz|''stringlength''}}</nowiki> (pad with zeros to the right or left; an alternative padding string can be given as a third parameter) |
| * <tt>{{plural:''n''|''is''|''are''}}</tt> (produces alternative text according to whether ''n'' is greater than 1) | | * <nowiki>{{plural:''n''|''is''|''are''}}</nowiki> (produces alternative text according to whether ''n'' is greater than 1) |
| * <tt>{{#time: format string | date/time object }}</tt> (for date/time formatting; also <tt>#timel</tt> for local time. Covered at the [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions extension documentation page].) | | * <nowiki>{{#time: format string | date/time object }}</nowiki> (for date/time formatting; also <nowiki>#timel</nowiki> for local time. Covered at the [http://www.mediawiki.org/wiki/Help:Extension:ParserFunctions extension documentation page].) |
|
| |
|
| === Paths === | | === Paths === |
| * <tt>{{localurl:''page name''}}</tt>, <tt>{{localurl:''page name''|''query string''}}</tt> (relative path to the title) | | * <nowiki>{{localurl:''page name''}}</nowiki>, <nowiki>{{localurl:''page name''|''query string''}}</nowiki> (relative path to the title) |
| * <tt>{{fullurl:''page name''}}</tt>, <tt>{{fullurl:''page name''|''query_string''}}</tt> (absolute path to the title) | | * <nowiki>{{fullurl:''page name''}}</nowiki>, <nowiki>{{fullurl:''page name''|''query_string''}}</nowiki> (absolute path to the title) |
| * <tt>{{filepath:''file name''}}</tt> (absolute URL to a media file) | | * <nowiki>{{filepath:''file name''}}</nowiki> (absolute URL to a media file) |
| * <tt>{{urlencode:''string''}}</tt> (input encoded for use in URLs) | | * <nowiki>{{urlencode:''string''}}</nowiki> (input encoded for use in URLs) |
| * <tt>{{anchorencode:''string''}}</tt> (input encoded for use in URL section anchors) | | * <nowiki>{{anchorencode:''string''}}</nowiki> (input encoded for use in URL section anchors) |
| * <tt>{{ns:''n''}}</tt> (name for the namespace with index ''n''; use <tt>{{nse:}}</tt> for URL-encoded equivalent) | | * <nowiki>{{ns:''n''}}</nowiki> (name for the namespace with index ''n''; use <nowiki>{{nse:}}</nowiki> for URL-encoded equivalent) |
| * <tt>{{#rel2abs: ''path'' }}</tt> (converts a relative file path to absolute; see the extension documentation above) | | * <nowiki>{{#rel2abs: ''path'' }}</nowiki> (converts a relative file path to absolute; see the extension documentation above) |
| * <tt>{{#titleparts: pagename | number of segments to return | first segment to return }}</tt> (splits title into parts; see the extension documentation above) | | * <nowiki>{{#titleparts: pagename | number of segments to return | first segment to return }}</nowiki> (splits title into parts; see the extension documentation above) |
|
| |
|
| === Conditional expressions === | | === Conditional expressions === |
Line 105: |
Line 101: |
|
| |
|
|
| |
|
| * <tt>{{#expr: ''expression'' }}</tt> (evaluates the given expression; see [http://en.wikipedia.org/wiki/Help:Calculation Help:Calculation] on Wookieepedia) | | * <nowiki>{{#expr: ''expression'' }}</nowiki> (evaluates the given expression; see [http://en.wikipedia.org/wiki/Help:Calculation Help:Calculation] on Wookieepedia) |
| * <tt>{{#if: ''test string'' | ''value if non-empty'' | ''value if empty'' }}</tt> (selects one of two values based on whether the test string is empty) | | * <nowiki>{{#if: ''test string'' | ''value if non-empty'' | ''value if empty'' }}</nowiki> (selects one of two values based on whether the test string is empty) |
| * <tt>{{#ifeq: ''string 1'' | ''string 2'' | ''value if equal'' | ''value if unequal'' }}</tt> (selects one of two values based on whether the test strings are equal – numerically if applicable) | | * <nowiki>{{#ifeq: ''string 1'' | ''string 2'' | ''value if equal'' | ''value if unequal'' }}</nowiki> (selects one of two values based on whether the test strings are equal – numerically if applicable) |
| * <tt>{{#iferror: ''test string'' | ''value if error'' | ''value if correct'' }}</tt> (selects value based on whether the test string generates a parser error) | | * <nowiki>{{#iferror: ''test string'' | ''value if error'' | ''value if correct'' }}</nowiki> (selects value based on whether the test string generates a parser error) |
| * <tt>{{#ifexpr: ''expression'' | ''value if true'' | ''value if false'' }}</tt> (selects value based on evaluation of expression) | | * <nowiki>{{#ifexpr: ''expression'' | ''value if true'' | ''value if false'' }}</nowiki> (selects value based on evaluation of expression) |
| * <tt>{{#ifexist: ''page title'' | ''value if exists'' | ''value if doesn't exist'' }}</tt> (selects value depending on whether a page title exists) | | * <nowiki>{{#ifexist: ''page title'' | ''value if exists'' | ''value if doesn't exist'' }}</nowiki> (selects value depending on whether a page title exists) |
| * <tt>{{#switch: test | case1 = value for case 1 | ... | default }}</tt> (provides alternatives based on the value of the test string) | | * <nowiki>{{#switch: test | case1 = value for case 1 | ... | default }}</nowiki> (provides alternatives based on the value of the test string) |
| For the use of these functions in tables, see [http://en.wikipedia.org/wiki/Wikipedia:Conditional_tables Conditional tables]. | | For the use of these functions in tables, see [http://en.wikipedia.org/wiki/Wikipedia:Conditional_tables Conditional tables]. |
|
| |
|
|
| |
|
| [[Category:DJB Help]] | | [[Category:DJB Help]] |