Template:Item/doc

来自Terraria Wiki
跳转至: 导航搜索

An all-in-one template for display item name/icon/link.

By default, displays a link to the item and adds an item icon in front of it.

Usage[编辑源代码]

All parameters are optional. Despite this, some combinations are invalid and may cause errors, e.g. {{item|icons=no|mode=image}}

See examples below for more details.

unnamed parameter 1

Default item display name, link target, and image file name.

unnamed Parameter 2

Custom link text, which can include line breaks (<br />) and other wikitext. If an 's', 'es', 'ies' or 'ves' is passed as the custom text, it will be appended to the end of the item name.

mode

Display mode. It can be:

  • image(Preferred) or imageonly or onlyimage means only image will be displayed;
  • text(Preferred) or noimage means no image will be displayed;
  • table(Preferred) or 2-cell will output 2 cells code for table. This is roughly a shortcut for {{item|mode=image|itemname}} || {{item|mode=text|itemname}}

Use preferred values as much as possible to get the best performance.

image

image filename, no brackets nor "File:"(must include file extension, eg. Parrot.png).

You can specify multiple images, just seperate filenames with slashes(eg. Parrot.png/Parrot (placed).png).

size

Custom graphic size (Read Extended image syntax for details).

You can specify multiple sizes, just seperated with slashes(eg. 32px/24x24px).

When multiple images specified:

    • If only one size specified, it will apply to all images
    • if size is less then image, extra images will be displayed as if they don't have size argument
    • if size is more then image, extra sizes will simply be ignored.
ext

image file extension, default is png. Only valid when there is no image input.

link

Custom link target. If blank given(i.e. |link=|), it will be no link(See example below).

nolink = y/yes

Same as |link=|, only valid when there is no link input. If you use |link=somelink|nolink=y, it will be ignored.

anchor = y/yes

If set, will create an anchor for {{{1}}}.

note

Extra note text. By default, it will displayed as smaller and gray text between item name and platform icons , and without link on it.

note2

Another note text. By default, it will displayed as gray txt in normal size, without link, and always take a single line.

wrap = y/yes

Only valid when there is no id= or note2= input. If set, platform icons and/or note will be displayed in new line.

icons = n/no/y/yes

n/no=suppresses the platform icons; default is yes.

id

Number, will display items(or other type) ID infomation.

type

the type of ID, case-insensitive, default is item, only valid when id is sepcified. can be tile, wall, npc, mount, buff, debuff, projectile, or armor. All other values are treated as item.

small = y/yes

Reduces the size of the platform icons (useful when space is an issue).

class

Custom Css class(es). There're some predefined classes for certain formatting purpose(see examples below). You can add yours if needed.

css or style

Custom css style rules.

Examples[编辑源代码]

Basic[编辑源代码]

Result Code Note
床 {{item|Bed}} Basic usage.
Any BedAny Bed {{item|Bed|Any Bed}} Custom text.
床 蝴蝶蝴蝶 {{item|Bed|s}} {{item|Butterfly|ies}} plural.
血肉墙血肉墙 {{item|Wall of Flesh|size=32px}} custom image size. (Read Extended image syntax for details).
Wall ofFleshWall of
Flesh
{{item|Wall of Flesh|size=32px|Wall of<br/>Flesh}} Custom text in multiple lines.
宝藏袋宝藏袋电脑版主机版 {{item|Treasure Bag|s|ext=gif}} Custom image file extension.
宝藏袋宝藏袋(Expert Mode)电脑版主机版 {{item|Treasure Bag|s|note={{small|(Expert Mode)}}|ext=gif}} Note text.
鹦鹉宠物鹦鹉宠物 {{item|Pet Parrot|image=Parrot.png|Parrot Pet}} Custom image file name.
鹦鹉宠物鹦鹉宠物 {{item|Pet Parrot|image=Parrot.png|Parrot Pet|ext=jpg}} Will display Parrot.png, ext is ignored when image specified.
鹦鹉宠物鹦鹉宠物 {{item|Parrot|link=Pet Parrot|Parrot Pet}} Custom link target.
蜜蜡蜜蜡主机版移动版3DS版 {{item|Beeswax|link=}} Unlinked.
蜜蜡蜜蜡主机版移动版3DS版 {{item|Beeswax|nolink=y}} Unlinked.
蜜蜡蜜蜡主机版移动版3DS版 {{item|Beeswax|nolink=y|link=Bee}} if link is specified, it will override unlink=y.
蜜蜡蜜蜡主机版移动版3DS版 {{item|Beeswax|small=y}} Small platform icons.
蜜蜡蜜蜡 {{item|Beeswax|icons=no}} Don't display platform icons.(Will be faster)
蜜蜡蜜蜡主机版移动版3DS版
内部物品 ID:5019
{{item|Beeswax|id=5019}} With Item ID infomation
宠物土蜂宠物土蜂主机版移动版3DS版
内部增益 ID:204
{{item|Pet Tiphia|id=204|type=buff}} Other type of ID, in this case, Buff ID.
向导向导
内部 NPC ID:22
{{item|Guide|id=22|type=npc}} NPC ID.
蜜蜡蜜蜡主机版移动版3DS版
内部物品 ID:5019
{{item|Beeswax|id=5019|anchor}} Create an anchor. Now {{PAGENAME}}#Beeswax will link to here.

Multiple images[编辑源代码]

Result Code Note
熔炉熔炉熔炉 {{item|Furnace|image=Furnace.png/Furnace_(placed).gif}} Multiple images with auto size.
熔炉熔炉熔炉 {{item|Furnace|image=Furnace.png/Furnace_(placed).gif|size=20px}} Only one size specified, all images will use this size.
熔炉熔炉熔炉 {{item|Furnace|image=Furnace.png/Furnace_(placed).gif|size=30px/20px}} Multiple images with multiple sizes.
熔炉熔炉熔炉 {{item|Furnace|image=Furnace.png/Furnace_(placed).gif|size=30px/20px/300px}} Size is more them images, extra size is ignored.
熔炉熔炉熔炉熔炉 {{item|Furnace|image=Furnace.png/Furnace_(placed).gif/Hellforge.png|size=16px/50px}} Size is less then image, extra image will use auto size.

Wrap, id and note2[编辑源代码]

wrap is valid only when id and note2 are not specified.

Result Code Note
蜜蜡蜜蜡主机版移动版3DS版 {{item|Beeswax|wrap=y}} If there are platform icons and no note, platform icons will wrap to next line. note that platform icons are displayed in reduced size.
床(some note) {{item|bed|wrap=y|note=(some note)}} If there are some note, note will wrap next line.
蜜蜡蜜蜡主机版移动版3DS版(some note) {{item|Beeswax|wrap=y|note=(some note)}} If there are some note, note will display in next line, and platform icons will display in same line.
蜜蜡蜜蜡(some note)主机版移动版3DS版
内部物品 ID:234
{{item|Beeswax|wrap=y|note=(some note)|id=234}} If id is specified, note and eicons will displayed in same line, even if wrap=y.
蜜蜡蜜蜡主机版移动版3DS版
some other notes.
{{item|Beeswax|wrap=y|note2=some other notes.}} note2 is similar.
蜜蜡蜜蜡主机版移动版3DS版
some other notes.
内部物品 ID:2384
{{item|Beeswax|id=2384|note2=some other notes.}} id and note2 will always take a single line.

Display mode[编辑源代码]

Result Code Note
蜜蜡蜜蜡主机版移动版3DS版
内部物品 ID:2384
{{item|Beeswax|id=2384}} By default, it will display image and text info.
蜜蜡 {{item|Beeswax|mode=image|id=2384}} mode=image: Only image will be displayed, no text, no note, no id, and no platform icons.
蜜蜡主机版移动版3DS版(some note) {{item|Beeswax|mode=text|wrap=y|note=(some note)}} mode=text: image won't be displayed.
蜜蜡 蜜蜡主机版移动版3DS版
蝴蝶 蝴蝶(some note)
{| class="wikitable"
|{{item|Beeswax|mode=table}}
|-
|{{item|Butterfly|ies|note=(some note)|mode=table}}
|}
mode=table: output as two adjacent cells for table.

Css and predefined classes[编辑源代码]

Result Code Note
蜜蜡蜜蜡主机版移动版3DS版
内部物品 ID:2384
{{item|Beeswax|link=|id=2384|css=color:red;border: 2px solid blue;padding: 3px; background:#ccc}} Custom css rules.
蜜蜡蜜蜡主机版移动版3DS版
内部物品 ID:2384
{{item|Beeswax|id=2384|class=boldname}} Predefined class: boldname, item name will displayed in bold.
蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384
{{item|Beeswax|id=2384|note=note|note2=note2|class=notecolor}}
{{item|Beeswax|id=2384|note=note|note2=note2|class=note2color}}
{{item|Beeswax|id=2384|note=note|note2=note2|css=color:red|class=note2color}}
Predefined class: notecolor and note2color, note or note2 will display in normal(inherited) text color, respectively .
蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384
{{item|Beeswax|id=2384|note=note|note2=note2|class=notecolor}}
{{item|Beeswax|id=2384|note=note|note2=note2|class=note2color}}
Predefined class: notesize and note2size, note will display in normal size, or note2 will display in reduced size, respectively.
蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384
{{item|Beeswax|id=2384|note=note|note2=note2|class=left}}<br/>{{item|Beeswax|id=2384|note=note|note2=note2|class=center}}<br/>{{item|Beeswax|id=2384|note=note|note2=note2|class=right}} Predefined class: alignleft, aligncenter, and alignright, text-align = left, center, or right, respectively.
蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384

蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384
{{item|Beeswax|id=2384|note=note|note2=note2|class=textleft}}<br/>{{item|Beeswax|id=2384|note=note|note2=note2|class=textcenter}}<br/>{{item|Beeswax|id=2384|note=note|note2=note2|class=textright}} Predefined class: textleft, textcenter, and textright, Similar to alignleft/aligncenter/alignright, but only applied to text part.alignleft/center/right can use with text/align/center/right at same time.
蜜蜡主机版移动版3DS版
内部物品 ID:2384
{{item|Beeswax|id=2384|class=block|mode=text}} Predefined class: block, main item element and text element will display as block element(default is inline-block).It is usually only practical when mode=text.
蜜蜡蜜蜡note主机版移动版3DS版
note2
内部物品 ID:2384
{{item|Beeswax|id=2384|note=note|note2=note2|class=notesize notecolor boldname|css=color:red}} You can specify multiple classes, seperate with space, and can specify custom css rules at the same time.

Change default options[编辑源代码]

You can use {{item/options}} to set/get and reset some options' default value.

Usage[编辑源代码]

  • Set: {{item/options|nolink=y|smallicons=no|...}} or {{item/options|set|nolink=y|smallicons=no|...}}
  • get: {{item/options|get|nolink}}
  • reset: {{item/options|reset}} or {{item/options|resetall}}
NOTE: In order to avoid unwanted influences, it is very important to reset options as soon as possible. Especially in the template, you should reset options before the template ends.

All parameters:

unnamed parameter 1

Action. get or load means get the current value of a option, reset or resetall means reset all options to default value, other values(include none. if you want, recommend to use set for better readability) means set options' value.

unnamed Parameter 2

The name of option which you want to get its value, only valid when action is get. Can be small, smallicons, icons, mode, wrap, nolink, class, css or style.

small/smallicons = y/yes/n/no

Only valid when action is set. Turn on/off reduced size for platform icons. See {{item}}'s small parameter.

icons = y/yes/n/no

Only valid when action is set. Turn on/off platform icons display. When turn off, {{item}} will be faster. See {{item}}'s icons parameter.

mode

Only valid when action is set. Set the default value for {{item}}'s mode parameter. You can use any valid value for {{item}}'s mode parameter, and a invalid value(recommend to use default, all, or both for better readability) means change the mode back to default. See {{item}}'s mode parameter.

wrap = y/yes/n/no

Only valid when action is set. Turn on/off line wrap. See {{item}}'s wrap parameter.

anchor = y/yes/n/no

Only valid when action is set. Turn on/off anchor. See {{item}}'s anchor parameter.

nolink = y/yes/n/no

Only valid when action is set. Turn on/off no link option. See {{item}}'s nolink parameter.

class

Only valid when action is set. Default value for class. See {{item}}'s class parameter.

css/style

Only valid when action is set. Default value for css. See {{item}}'s css parameter.

See examples below for more details.

Example[编辑源代码]

Code output
By default: 

{{item|Beeswax|note=(note)}}

turn off platform icons: 
{{item/options|set|icons=no}}
{{item|Beeswax|note=(note)}}

turn on platform icons, and turn on small icons:
{{item/options|set|icons=y|smallicons=y}}
{{item|Beeswax|note=(note)}}

turn on line wrap, and set to text mode: 
{{item/options|set|wrap=y|mode=text}}
{{item|Beeswax|note=(note)}}

turn on no link mode: 
{{item/options|set|nolink=y}}
{{item|Beeswax|note=(note)}}

This will be overrided by '''<code>link=</code>'''

{{item|Beeswax|note=(note)|link=Bee}}

get current setting:

nolink = {{item/options|get|nolink}} ; 
wrap = {{item/options|get|wrap}} ;
mode = {{item/options|get|mode}} ;

reset all options: 
{{item/options|reset}}
{{item|Beeswax|note=(note)}}

custom css and class:
{{item/options|set|css=border:1px solid red;padding:3px}}
{{item|Beeswax|note=(note)}}
{{item/options|set|class=boldname}}
{{item|Beeswax|note=(note)}}

reset all:
{{item/options|resetall}}
{{item|Beeswax|note=(note)}}

By default:

蜜蜡蜜蜡(note)主机版移动版3DS版

turn off platform icons:

蜜蜡蜜蜡(note)

turn on platform icons, and turn on small icons:

蜜蜡蜜蜡(note)主机版移动版3DS版

turn on line wrap, and set to text mode:

蜜蜡主机版移动版3DS版(note)

turn on no link mode:

蜜蜡主机版移动版3DS版(note)

This will be overrided by link=

蜜蜡主机版移动版3DS版(note)

get current setting:

nolink = y ; wrap = y ; mode = text ;

reset all options:

蜜蜡蜜蜡(note)主机版移动版3DS版

custom css and class:

蜜蜡蜜蜡(note)主机版移动版3DS版

蜜蜡蜜蜡(note)主机版移动版3DS版

reset all:

蜜蜡蜜蜡(note)主机版移动版3DS版


Promotional Content