Template:Item
This template uses Module:Item, a script written in the Lua programming language. Please see wikipedia:Lua and mw:Extension:Scribunto to learn more about Lua. |
This template is i18n-ready, which means it is easy to localize for different languages. Please see I18n & l10n for Templates to learn more. |
This template adds rows to the table "Imageinfo", which is declared by the template Image. View table.
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.
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) orimageonly
oronlyimage
means only image will be displayed;text
(Preferred) ornoimage
means no image will be displayed;table
(Preferred) or2-cell
will output 2 cells code for table. This is roughly a shortcut for{{item|mode=image|itemname}} || {{item|mode=text|itemname}}
htmltable
(Preferred) orhtml-2-cell
is similar totable
, but will produce a result suitable for html tables instead of mediawiki tables (roughly a shortcut for{{item|mode=image|itemname}} </td><td> {{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. Diverman.png).
You can specify multiple images, just seperate filenames with slashes(eg. Diverman.png/Soul Forge (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 note2= input. If set, note will be displayed in new line.
- 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 |
---|---|---|
Stardust | {{item|Stardust}} |
Basic usage. |
Star Powder | {{item|Stardust|Star Powder}} |
Custom text. |
Stardusts Demon Trophies | {{item|Stardust|s}} {{item|Demon Trophy|ies}} |
Plural. |
The Hive Mind | {{item|The Hive Mind|size=32px}} |
Custom image size. (Read Extended image syntax for details). |
Hive Mind |
{{item|The Hive Mind|size=32px|Hive<br/>Mind}} |
Custom text in multiple lines. |
Treasure Bags | {{item|Treasure Bag|s|ext=gif}} |
Custom image file extension. |
Treasure Bags(Expert Mode) | {{item|Treasure Bag|s|note=(Expert Mode)|ext=gif}} |
Note text. |
Ocean Spirit | {{item|Strange Orb|image=Ocean Spirit.png|Ocean Spirit}} |
Custom image file name. |
Strange Orb | {{item|Strange Orb|image=Ocean Spirit.png|size=75px}} |
Custom image size. |
Ocean Spirit | {{item|Strange Orb|image=Ocean Spirit.png|Ocean Spirit|ext=jpg}} |
Will display Ocean Spirit.png, ext is ignored when image is specified.
|
Ocean Spirit | {{item|Ocean Spirit|link=Strange Orb|Ocean Spirit}} |
Custom link target. |
Stardust | {{item|Stardust|link=}} |
Unlinked. |
Stardust | {{item|Stardust|nolink=y}} |
Unlinked. |
Stardust | {{item|Stardust|nolink=y|link=Astral Bar}} |
if link is specified, it will override unlink=y .
|
Stardust | {{item|Stardust|anchor=y}} |
Create an anchor. Now {{PAGENAME}}#Stardust will link to here. |
Multiple images
Result | Code | Note |
---|---|---|
Draedon's Forge | {{item|Draedon's Forge|image=Draedon's Forge.png/Draedon's Forge_(placed).png}} |
Multiple images with auto size. |
Draedon's Forge | {{item|Draedon's Forge|image=Draedon's Forge.png/Draedon's Forge_(placed).gif|size=20px}} |
Only one size specified, all images will use this size. |
Draedon's Forge | {{item|Draedon's Forge|image=Draedon's Forge.png/Draedon's Forge_(placed).gif|size=30px/20px}} |
Multiple images with multiple sizes. |
Draedon's Forge | {{item|Draedon's Forge|image=Draedon's Forge.png/Draedon's Forge_(placed).gif|size=30px/20px/300px}} |
Size is more than images, extra size is ignored. |
Draedon's Forge | {{item|Draedon's Forge|image=Draedon's Forge.png/Draedon's Forge_(placed).gif/Ashen Altar.png|size=16px/50px}} |
Size is less than image, extra image will use auto size. |
Wrap and note2
wrap
is valid only when note2
is not specified.
Result | Code | Note |
---|---|---|
Stardust(some note) | {{item|Stardust|wrap=y|note=(some note)}} |
If there is a note, note will display on next line. |
Stardust some other notes. |
{{item|Stardust|wrap=y|note2=some other notes.}} |
If note2 is specified, note will be displayed on the same line, even if wrap=y .
|
Display mode
Result | Code | Note | ||||
---|---|---|---|---|---|---|
Stardust | {{item|Stardust}} |
By default, it will display image and text info. | ||||
{{item|Stardust|mode=image}} |
mode=image : Only image will be displayed, no text, no note.
| |||||
Stardust(some note) | {{item|Stardust|mode=text|wrap=y|note=(some note)}} |
mode=text : image won't be displayed.
| ||||
|
{| class="wikitable" |{{item|Stardust|mode=table}} |- |{{item|Demon Trophy|ies|note=(some note)|mode=table}} |} |
mode=table : output as two adjacent cells for table.
|
Css and predefined classes
Result | Code | Note |
---|---|---|
Stardust | {{item|Stardust|link=|css=color:red;border: 2px solid blue;padding: 3px; background:#ccc}} |
Custom css rules. |
Stardust | {{item|Stardust|class=boldname}} |
Predefined class: boldname , item name will displayed in bold.
|
Stardustnote note2 Stardustnote note2 Stardustnote note2 |
{{item|Stardust|note=note|note2=note2|class=notecolor}} |
Predefined class: notecolor and note2color , note or note2 will display in normal(inherited) text color, respectively .
|
Stardustnote note2 Stardustnote note2 |
{{item|Stardust|note=note|note2=note2|class=notecolor}} |
Predefined class: notesize and note2size , note will display in normal size, or note2 will display in reduced size, respectively.
|
Stardustnote note2 Stardustnote note2 Stardustnote note2 |
{{item|Stardust|note=note|note2=note2|class=left}}<br/>{{item|Stardust|note=note|note2=note2|class=center}}<br/>{{item|Stardust|note=note|note2=note2|class=right}} |
Predefined class: alignleft , aligncenter , and alignright , text-align = left, center, or right, respectively.
|
Stardustnote note2 Stardustnote note2 Stardustnote note2 |
{{item|Stardust|note=note|note2=note2|class=textleft}}<br/>{{item|Stardust|note=note|note2=note2|class=textcenter}}<br/>{{item|Stardust|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.
|
Stardust | {{item|Stardust|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 .
|
Stardustnote note2 |
{{item|Stardust|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|...}}
or{{item/options|set|nolink=y|...}}
- get:
{{item/options|get|nolink}}
- reset:
{{item/options|reset}}
or{{item/options|resetall}}
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 mode
, wrap
, nolink
, class
, css
or style
.
- 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|Stardust|note=(note)}} turn on line wrap, and set to text mode: {{item/options|set|wrap=y|mode=text}} {{item|Stardust|note=(note)}} turn on no link mode: {{item/options|set|nolink=y}} {{item|Stardust|note=(note)}} This will be overrid by '''<code>link=</code>''' {{item|Stardust|note=(note)|link=Astral Bar}} 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|Stardust|note=(note)}} custom css and class: {{item/options|set|css=border:1px solid red;padding:3px}} {{item|Stardust|note=(note)}} {{item/options|set|class=boldname}} {{item|Stardust|note=(note)}} reset all: {{item/options|resetall}} {{item|Stardust|note=(note)}} |
By default: Stardust(note) turn on line wrap, and set to text mode: Stardust(note) turn on no link mode: Stardust(note) This will be overrid by Stardust(note) get current setting: nolink = y ; wrap = y ; mode = text ; reset all options: Stardust(note) custom css and class: Stardust(note) Stardust(note) reset all: Stardust(note)
|