Template:ItemCard: Difference between revisions

Use cargo for information lookup, added basic error handling
(Correct title when using empty text= parameter)
(Use cargo for information lookup, added basic error handling)
Line 1:
<includeonly>{{#ifeq: {{{2|}}} | block | {{#vardefine:block_output | true }} }}{{#ifeq: {{{3|}}} | block | {{#vardefine:block_output | true }} }}{{#ifeq: {{{4|}}} | block | {{#vardefine:block_output | true }} }}{{#ifeq: {{{5|}}} | block | {{#vardefine:block_output | true }} }}{{#vardefine:dpldataitemdata | {{#dplcargo_query:| category=Items | titlematch=%/{{{1|}}} | format = ,,{{!}}%PAGE%, | include = {Item}:Icon:NameEN }} }}{{#vardefine:Icon | {{#explode:{{#var:dpldata}}|{{!}}|0}} }}{{#vardefine:Name | {{#explode:{{#var:dpldata}}|{{!}}|1}} }}{{#vardefine:Page | {{#explode:{{#var:dpldata}}|{{!}}|2}} }}{{#ifeq:{{{text|+}}}|{{{text|-}}} | {{#vardefine:DisplayName | {{{text|}}} }} | {{#vardefine:DisplayName | {{#var:Name}} }} }}{{#if: {{#var:block_output}} | <span style="display:inline-block;text-align:center;width:{{{2|32px}}}"> }}[[File:{{#var:Icon}}|{{{2|32px}}}|{{#if: {{#var:DisplayName}} | {{#var:DisplayName}} | {{#var:Name}} }}|link={{#var:Page}}|class=itemcard]]{{#if: {{#var:DisplayName}} | [[{{#var:Page}}|{{#var:DisplayName}}]] }}{{#if: {{#var:block_output}} | </span> }}{{#vardefine:block_output | }}{{#vardefine:Name | }}{{#vardefine:Icon | }}{{#vardefine:Page | }}{{#vardefine:DisplayName | }}</includeonly>
tables=items
|fields= CONCAT(Icon, '{{!}}', NameEN, '{{!}}', _pageName)=Item
|where=items.NameEN = '{{{1|}}}'
|limit=1
|intro=
|outro=
|default=Icon_Error.png{{!}}Item not found{{!}}Category:Items
|more results text=
|format=list
|no html
}} }}{{#vardefine:Icon | {{#explode:{{#var:itemdata}}|{{!}}|0}} }}{{#vardefine:Name | {{#explode:{{#var:itemdata}}|{{!}}|1}} }}{{#vardefine:Page | {{#explode:{{#var:itemdata}}|{{!}}|2}} }}{{#ifeq:{{{text|+}}}|{{{text|-}}} | {{#vardefine:DisplayName | {{{text|}}} }} | {{#vardefine:DisplayName | {{#var:Name}} }} }}{{#if: {{#var:block_output}} | <span style="display:inline-block;text-align:center;width:{{{2|32px}}}"> }}[[File:{{#var:Icon}}|{{{2|32px}}}|{{#if: {{#var:DisplayName}} | {{#var:DisplayName}} | {{#var:Name}} }}|link={{#var:Page}}|class=itemcard]]{{#if: {{#var:DisplayName}} | [[{{#var:Page}}|{{#var:DisplayName}}]] }}{{#if: {{#var:block_output}} | </span> }}{{#vardefine:block_output | }}{{#vardefine:Name | }}{{#vardefine:Icon | }}{{#vardefine:Page | }}{{#vardefine:DisplayName | }}
</includeonly>
<noinclude>
Outputs an image of the item that links back to its page.
Line 9 ⟶ 21:
*<code>block</code>: display card as a block element the width of the icon, with item name underneath
==Examples==
{{ItemCard.cargo|Teddy Bear with Bow|90px|block}}
 
{{ItemCard|Wavecat Pillow|64px}}{{ItemCard|Wavecat Pillow|48px|text=AltName}}{{ItemCard|Wavecat Pillow}}