Template:ItemCard: Difference between revisions

From Blue Archive Wiki
Jump to navigation Jump to search
Content added Content deleted
(Correct title when using empty text= parameter)
(Use cargo for information lookup, added basic error handling)
Line 1: 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:dpldata | {{#dpl:| 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>
<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:itemdata | {{#cargo_query:
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>
<noinclude>
Outputs an image of the item that links back to its page.
Outputs an image of the item that links back to its page.
Line 9: Line 21:
*<code>block</code>: display card as a block element the width of the icon, with item name underneath
*<code>block</code>: display card as a block element the width of the icon, with item name underneath
==Examples==
==Examples==
{{ItemCard|Teddy Bear with Bow|90px|block}}
{{ItemCard.cargo|Teddy Bear with Bow|90px|block}}


{{ItemCard|Wavecat Pillow|64px}}{{ItemCard|Wavecat Pillow|48px|text=AltName}}{{ItemCard|Wavecat Pillow}}
{{ItemCard|Wavecat Pillow|64px}}{{ItemCard|Wavecat Pillow|48px|text=AltName}}{{ItemCard|Wavecat Pillow}}

Revision as of 03:27, 7 May 2022


Outputs an image of the item that links back to its page.

Usage

{{ItemCard|Name[|32px[|text=AltName][|block]]}}

Options

  • 32px: image size with statement format corresponding to MediaWiki File size style (32px for set width, x32px for set height, 32x32px for arbitrary scaling); should be a width only value if using block output
  • text: alternative item name to display. Use text= to disable text output entirely
  • block: display card as a block element the width of the icon, with item name underneath

Examples

Template:ItemCard.cargo

Wavecat PillowWavecat Pillow

AltNameAltName

Wavecat PillowWavecat Pillow