Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Template:Item icon: Difference between revisions

Template page
Update: use pagename directly, escape ' but not "
wrap by default, unless specifying nowrap. This matches Template:IconLink
 
(40 intermediate revisions by 4 users not shown)
Line 1: Line 1:
<includeonly><onlyinclude>{{#cargo_query:
<includeonly>{{#lvardef: margin | {{#expr: 0.015 * {{{size|40}}} }} }}{{#lvardef: size | {{{size|40}}} }}<span class="bg3wiki-itemicon-wrapper {{#if:{{{nowrap|}}}|nowrap|wrap}}" style="{{#if:{{{no_padding|}}}||margin-left: {{#lvar:margin}}rem;}}">{{#if:{{{override_icon|}}}
tables=item_icon
|{{ItemIcon Internal|{{{override_icon}}}|{{#lvar:size}}|{{{override_rarity}}}|{{{show_rarity|}}}|{{{name}}} }}
|fields=TRIM(icon),CONCAT('', '{{{size|40}}}')
|{{#cargo_query:
|where=item_icon._pageName="{{{name}}}"
  tables = item_icon
|limit=1
  | fields =
|order by=item_icon.name
    TRIM(icon) = icon,
|default=
    CONCAT('', '{{#lvar:size}}') = size,
|more results text=
    LOWER(rarity) = rarity,
|format=template
    CONCAT('', '{{{show_rarity|}}}') = show_rarity,
|template=ItemIcon Internal
    CONCAT('', "{{{name}}}") = name
}}{{#if:{{{show_name|}}}|[[{{{name}}}]] }}</onlyinclude></includeonly><noinclude>
  | where = {{#if: {{{uid|}}} | item_icon.uid = "{{{uid}}}" | item_icon._pageName="{{{name}}}" }}
 
  | limit = 1
<!-- Cargo table definition -->
  | order by = item_icon._pageName
{{#cargo_declare:
  | default = {{ItemIcon Internal|{{{name}}} Unfaded Icon.png|{{#lvar:size}}|common| true|{{{name}}}|missing=true}}
_table = item_icon
  | more results text =
|name = String
  | format = template
|icon = File
  | template = ItemIcon Internal
}}
}}
}}{{#if:{{{show_name|}}}|<span class="bg3wiki-itemicon-link" style="margin-left: 1ch">[[{{{name}}}{{#if:{{{alias|}}}|{{!}}{{{alias}}}}}]]</span>}}{{#if:{{{wrap|}}}|{{Main only|[[Category:Pages using deprecated parameters]]}}}}</span></includeonly><noinclude>{{/doc}}


This template fetches an icon for an item using Cargo. It also declares the Cargo table for the "item_icon" table that stores this information. The information is uploaded using the standard item descriptions.
== Template Data Section ==
 
Usage: <pre>{{ItemIcon
|name=the name of the icon page
|size=(optional) the size of the icon
|show_name=(optional) Whether to show the name. Any value will show the name of the item as a link. Omit to hide it.
}}</pre>
 
== Templates ==
 
Copy-ready template (no item name): <code><nowiki>{{ItemIcon|name=}}</nowiki></code>
 
Copy-ready template (with item name): <code><nowiki>{{ItemIcon|name=|show_name=true}}</nowiki></code>
 
== Examples ==
<code><nowiki>{{ItemIcon|name=Potion of Healing}}</nowiki></code> {{ItemIcon|name=Potion of Healing}}
 
<code><nowiki>{{ItemIcon|name=Potion of Healing|size=30}}</nowiki></code> {{ItemIcon|name=Potion of Healing|size=30}}
 
<code><nowiki>{{ItemIcon|name=Potion of Healing|size=24|show_name=true}}</nowiki></code> {{ItemIcon|name=Potion of Healing|size=24|show_name=true}}
 
<code><nowiki>{{ItemIcon|name=The Red Knight's Final Stratagem}} (testing that pages with ' work)</nowiki></code> {{ItemIcon|name=The Red Knight's Final Stratagem}}


</noinclude>
<templatedata>
{
"params": {
"size": {
"description": "The height of the item icon.",
"suggestedvalues": [
"40",
"25",
"20"
],
"default": "40",
"type": "number"
},
"name": {
"description": "The name of the icon. Identical to the item's page name.",
"example": "Potion of Healing",
"required": true,
"type": "wiki-page-name"
},
"show_name": {
"description": "If non-empty, will link the icon as well.",
"type": "boolean"
},
"no_padding": {
"description": "Whether to remove exterior padding. Advanced use."
},
"show_rarity": {
"description": "If non-empty, will display an icon border corresponding to the rarity.",
"type": "boolean"
},
"override_icon": {
"description": "If provided, will override the icon with the provided one.",
"type": "string"
},
"override_rarity": {
"description": "If provided, will replace the fetched rarity.",
"type": "string"
},
"alias": {
"description": "An alias for the item.",
"type": "string"
},
"wrap": {
"description": "If non-empty, will allow the item icon to wrap.",
"type": "boolean"
},
"uid": {
"description": "If specified, will instead search by UID.",
"type": "string"
}
},
"description": "Inserts an item's icon automatically. Can also display a link to the item.",
"paramOrder": [
"name",
"uid",
"size",
"show_name",
"no_padding",
"show_rarity",
"override_icon",
"override_rarity",
"alias",
"wrap"
],
"format": "inline"
}
</templatedata></noinclude>