魔术字
出自org
| 所在位置:首页 > 编辑手册 > 魔术字 |
Taken from http://meta.wikimedia.org/wiki/Help:Magic_words. Original content licensed under the GFDL.
This is an organised index of Magic words used in MediaWiki. Tags such as "[MW1.5+]" indicate the version that first supported the magic word. "XYZ" indicates user input, which is used in the example.
目录 |
[编辑] Table of contents
| Word | Explanation | JAMWiki Status |
|---|---|---|
| __NOTOC__ | Hides ToC on the current page. | Supported |
| __FORCETOC__ | Forces the table of contents to appear. | Supported |
| __TOC__ | Places a ToC here (overriding any __NOTOC__). | Supported |
[编辑] More magic
| Word | Explanation | JAMWiki Status |
|---|---|---|
| __NOEDITSECTION__ | Hides the edit links beside headings. | Unsupported |
| __NEWSECTIONLINK__ | [MW1.7+] Gives a "+"-link next to the edit-tab to make a new section on a non-talk page. | Unsupported |
| __NOCONTENTCONVERT__ __NOCC__ | Don't perform the content language conversion (character and phase) in article display; for example, Chinese zh with zh_cn, zh_tw, zh_sg, zh_hk. | Unsupported |
| __NOGALLERY__ | [MW1.7+] This magic word allows images in category pages to be displayed as inline links instead of gallery. | Unsupported |
| __NOTITLECONVERT__ __NOTC__ | Like __NOCC__ but affecting article title only. | Unsupported |
| __END__ | Allows for trailing whitespace to be included in the page save. | Unsupported |
| __START__ | This magic word has no effect but an ID in MagicWord.php (MAG_START).
| Unsupported |
[编辑] Variables
[编辑] Time
The time in UTC.
| Word | Example | Explanation | JAMWiki Status |
|---|---|---|---|
| {{CURRENTDAY}} | 2
| Displays the current day in numeric form. | Supported |
| {{CURRENTDAY2}} | 02
| [MW1.6+] Same as {{CURRENTDAY}}, but with leading zero (01 .. 31). | Supported |
| {{CURRENTDAYNAME}} | 星期五
| Name of the day in the language of the project or English. | Supported |
| {{CURRENTDOW}} | 5
| Same as {{CURRENTDAYNAME}}, but as a number (0=Sunday, 1=Monday...). | Supported |
| {{CURRENTMONTH}} | 01
| The number 01 .. 12 of the month. | Supported |
| {{CURRENTMONTHABBREV}} | 1月
| [MW1.5+] Same as {{CURRENTMONTH}}, but in abbreviated form as Jan .. Dec. | Supported |
| {{CURRENTMONTHNAME}} | 1月
| Same as {{CURRENTMONTH}}, but in named form January .. December. | Supported |
| {{CURRENTTIME}} | 15:50
| The current time (00:00 .. 23:59). | Supported |
| {{CURRENTHOUR}} | 15
| The current hour (00 .. 23). | Supported |
| {{CURRENTWEEK}} | 1
| Number of the current week (1-53) according to ISO 8601 with no leading zero. | Supported |
| {{CURRENTYEAR}} | 2009
| Returns the current year. | Supported |
| {{CURRENTTIMESTAMP}} | 20090102155035
| [MW1.7+] ISO 8601 time stamp. | Supported |
[编辑] Local time
The time depending on the local timezone of the wiki. (All words [MW1.8+] )
| Word | Example | Explanation | JAMWiki Status |
|---|---|---|---|
| {{LOCALDAY}} | 2
| Displays the local day of the month in numeric form. | Supported |
| {{LOCALDAY2}} | 02
| Same as {{LOCALDAY}}, but with a leading zero (01 .. 31). | Supported |
| {{LOCALDAYNAME}} | 星期五
| Name of the day in the language of the project or English. | Supported |
| {{LOCALDOW}} | 5
| Same as {{LOCALDAYNAME}}, but as a number (0=Sunday, 1=Monday...). | Supported |
| {{LOCALMONTH}} | 01
| The number 01 .. 12 of the month. | Supported |
| {{LOCALMONTHABBREV}} | 1月
| Same as {{LOCALMONTH}}, but in abbreviated form as Jan .. Dec. | Supported |
| {{LOCALMONTHNAME}} | 1月
| Same as {{LOCALMONTH}}, but in named form as January .. December. | Supported |
| {{LOCALTIME}} | 23:50
| The local time (00:00 .. 23:59). | Supported |
| {{LOCALHOUR}} | 23
| The local hour (00 .. 23). | Supported |
| {{LOCALWEEK}} | 1
| Number of the local week (1-53) according to ISO 8601 with no leading zero. | Supported |
| {{LOCALYEAR}} | 2009
| Returns the local year. | Supported |
| {{LOCALTIMESTAMP}} | 20090102235035
| ISO 8601 time stamp. | Supported |
[编辑] Statistics
| Word | Example | Explanation | JAMWiki Status |
|---|---|---|---|
| {{CURRENTVERSION}} | 1.10.0
| [MW1.7+] Returns the current Wiki version. | Supported |
| {{NUMBEROFARTICLES}} {{NUMBEROFARTICLES:R}} | 463463
| A variable which returns the total number of articles on the Wiki. | Unsupported |
| {{NUMBEROFPAGES}} {{NUMBEROFPAGES:R}} | 2,6192619
| [MW1.7+] Returns the total number of pages. See here for details. | Supported |
| {{NUMBEROFFILES}} {{NUMBEROFFILES:R}} | 225225
| [MW1.5+] Returns the number of uploaded files (rows in the image table). | Supported |
| {{NUMBEROFUSERS}} {{NUMBEROFUSERS:R}} | 387387
| [MW1.7+] Returns the number of registered users (rows in the user table). | Supported |
| {{NUMBEROFADMINS}} {{NUMBEROFADMINS:R}} | 22
| [MW1.7+] Returns the number of administrators (sysop, bureaucrat, steward and checkuser). | Unsupported |
| {{PAGESINNAMESPACE}} | Template:PAGESINNAMESPACE
| Longer alias of PAGESINNS | Unsupported |
| {{PAGESINNS:ns}} {{PAGESINNS:ns:R}} | Template:PAGESINNS:ns:R
| [MW1.7+] Returns the number of pages in the given namespace. Disabled by default, enable with Template:H:mwg. | Unsupported |
[编辑] Page names and related info
| Word | Example | Explanation | JAMWiki Status |
|---|---|---|---|
| {{PAGENAME}} | 魔术字
| Returns the name of the current page, including all levels (Title/Subtitle). | Supported |
| {{PAGENAMEE}} | %E9%AD%94%E6%9C%AF%E5%AD%97
| More URL-friendly percent encoded special characters (To use an articlename in an external link). | Supported |
| {{SUBPAGENAME}} {{SUBPAGENAMEE}} | 魔术字
| [MW1.6+] Name of the current page, excluding parent pages ("Subtitle" on "Title/Subtitle") in namespaces supporting subpages, see Help:Link. | Supported |
| {{BASEPAGENAME}} {{BASEPAGENAMEE}} | 魔术字
| [MW1.7+] The basename of a subpage ("Title" on "Title/Subtitle"), see Help:Link. | Supported |
| {{NAMESPACE}} {{NAMESPACEE}} |
| Returns the name of the namespace the current page resides in. | Supported |
| {{FULLPAGENAME}} {{FULLPAGENAMEE}} | 魔术字
| [MW1.6+] Shorthands for NAMESPACE+PAGENAME | Supported |
| {{TALKSPACE}} {{TALKSPACEE}} | Talk
| [MW1.7+] Name of next odd namespace (e.g. 4 => 5) | Supported |
| {{SUBJECTSPACE}} {{SUBJECTSPACEE}} |
| [MW1.7+] Name of last even namespace (e.g. 5 => 4) | Supported |
| {{ARTICLESPACE}} {{ARTICLESPACEE}} |
| [MW1.7+] An alias for SUBJECTSPACE(E) | Supported |
| {{TALKPAGENAME}} {{TALKPAGENAMEE}} | Talk:魔术字
| [MW1.7+] FULLPAGENAME in its TALKSPACE | Supported |
| {{SUBJECTPAGENAME}} {{SUBJECTPAGENAMEE}} | 魔术字
| [MW1.7+] FULLPAGENAME in its SUBJECTSPACE | Supported |
| {{ARTICLEPAGENAME}} {{ARTICLEPAGENAMEE}} | 魔术字
| [MW1.7+] An alias for SUBJECTPAGENAME(E) | Supported |
| {{REVISIONID}} | 11755
| [MW1.5+] The unique identifying number of a page, see Help:Diff. | Unsupported |
| {{REVISIONDAY}} | 10
| [MW1.8+] The day on which the page was last modified. | Supported |
| {{REVISIONDAY2}} | 10
| [MW1.8+] The day on which the page was last modified, but with a leading zero (01 .. 31). | Supported |
| {{REVISIONMONTH}} | 3
| [MW1.8+] The month in which the page was last modified. | Supported |
| {{REVISIONYEAR}} | 2008
| [MW1.8+] The year in which the page was last modified. | Supported |
| {{REVISIONTIMESTAMP}} | 20080310134115
| [MW1.8+] ISO 8601 time stamp, indicating when the page was last modified. | Supported |
| {{SITENAME}} | org
| Value of Template:H:mwg. | Unsupported |
| {{SERVER}} | http://www.18dao.org
| Value of Template:H:mwg | Unsupported |
| {{SCRIPTPATH}} |
| [MW1.5+] Template:H:mwg | Unsupported |
| {{SERVERNAME}} | www.18dao.org
| [MW1.5+] Template:H:mwg | Unsupported |
[编辑] Parser functions
[编辑] Namespaces and URLs
| Word | Example | Explanation | JAMWiki Status |
|---|---|---|---|
| {{ns:}} | {{ns:4}} = org{{ns:project}} = org
| Returns the name of a given namespace number. | Unsupported |
| {{localurl:x y @}} {{localurle:x y @}} {{localurl:a|b=c}} | /X_y_%40
| Returns the local URL of a page (might not exist). Optional query parameter, see Help:Variable. | Unsupported |
| {{urlencode:x y @}} | x+y+%40
| [MW1.7+] Encodes variable values for use in external links. See here for details. | Unsupported |
| {{anchorencode:x #y @}} | x_.23y_.40
| [MW1.8+] Encodes variable values for use in external links. See here for details. | Unsupported |
| {{fullurl:x y @}} {{fullurle:x y @}} {{fullurl:m:a|b=c}} | http://www.18dao.org/X_y_%40 http://www.18dao.org/X_y_%40 http://www.18dao.org/index.php?title=M:a&b=c | [MW1.5+] Returns the full URL of a given page. Optional query parameter as for localurl:. | Unsupported |
[编辑] Formatting
| Word | Example | Explanation | JAMWiki Support |
|---|---|---|---|
| {{#language:}} | {{#language:da}} = Dansk
| [MW1.7+] Native name of language code. | Unsupported |
| {{lc:}} | {{lc:AbC dEf}} = abc def
| [MW1.5+] LowerCase | Unsupported |
| {{lcfirst:}} | {{lcfirst:Ab Cd}} = ab Cd
| [MW1.5+] LC first char. | Unsupported |
| {{uc:}} | {{uc:aBc DeF}} = ABC DEF
| [MW1.5+] UpperCase | Unsupported |
| {{ucfirst:}} | {{ucfirst:aB cD}} = AB cD
| [MW1.5+] UC first char. | Unsupported |
| {{formatnum:}} | {{formatnum:299792458}} = 299,792,458
| [MW1.7+] Add decimal separators according to the wiki's default locale. | Unsupported |
| {{padleft:}} {{padright:}} | {{padleft:bcd|6|a}} = aaabcd{{padright:bcd|6|a}} = bcdaaa
| [MW1.8+] Pads a string with a character to the specified width. | Unsupported |
[编辑] Template modifiers
| Usage | Explanation | JAMWiki Support |
|---|---|---|
| {{:xyz}} | A bare colon is not a template modifier, it's the prefix for the main namespace. Test e.g. article {{:UTC}} vs. template {{UTC}} | Supported |
| {{int:xyz}} | Shorthand for {{MediaWiki:xyz}}, rendered as <xyz> if MediaWiki:xyz doesn't exist. See Help:MediaWiki namespace. | Unsupported |
| {{msg:xyz}} | Try {{Template:xyz}} before magic word xyz, without this modifier it's the other way around. No additional effect if there is no template xyz. | Unsupported |
| {{msgnw:xyz}} | The unevaluated wikitext is rendered. See msgnw. | Unsupported |
| {{raw:xyz}} | [MW1.6+] Like {{msg:}} Template:Unclear [1]
| Unsupported |
| {{subst:xyz}} | In the wikitext, the tag is substituted by the content (single-level evaluation only), see Help:Substitution. | Unsupported |
[编辑] Image modifiers
- For details see wikipedia:Wikipedia:Extended image syntax.
These are image modifiers used in [[Image:title.ext|modifier|...|modifier]] links. Some are mutually exclusive, and then the last specified wins.
[编辑] Size
The last unrecognized modifier is used as caption for framed images or together with thumbnails. It's also used as description alt=text.
| Word | Usage | Explanation |
|---|---|---|
| framed frame enframed | [[Image:Mediawiki.png|framed]] | Places an image in a frame with a description. Uses original size. |
| thumbnail thumb | [[Image:Mediawiki.png|thumbnail]] | Modifies image size, sets it to dependant on user's favourite thumbnail size in their preferences. |
| thumb=xyz | [[Image:Mediawiki.png|thumb=Wiki.png]] | Manualthumb: instead of displaying an automatically-sized thumbnail for Mediawiki.png, display the image Wiki.png. |
| width px | [[Image:Mediawiki.png|40px]] | Scales image to given width in pixels |
[编辑] Position
The positions are mutually exclusive, the last specified wins. Template:- can stop floating. For inline images only modifier px (see above) is supported.
| Word | Usage | Explanation |
|---|---|---|
| right | [[Image:Mediawiki.png|right]] | Modifies position, floats the image to the right. |
| left | [[Image:Mediawiki.png|left]] | Modifies position, floats the image to the left. |
| none | [[Image:Mediawiki.png|none]] | Explicitly states that the image should not float. |
| center centre | [[Image:Mediawiki.png|center]] | Modifies position, like none but centered. |
[编辑] Miscellany
| Word | Example | Explanation | JAMWiki Status |
|---|---|---|---|
| {{DISPLAYTITLE:xyz}} | default disabled | [MW 1.7+] Set the page's title per the spec, see Template:H:mwg. | Unsupported |
| {{DIRMARK}} {{DIRECTIONMARK}} |
| [MW1.7+] u+200E left to right or u+200D right to left mark | Unsupported |
| {{CONTENTLANGUAGE}} | zh-cn
| [MW1.7+] Default content Template:H:mwg | Unsupported |
| #redirect | #REDIRECT [[target]]at top of source page | Creates a redirect to another page. | Supported |
| 用户留言:新增留言 编辑留言 |
| 目前暂无留言 |


