Template:Item icon: Difference between revisions

Jump to navigation Jump to search
Code cleanup. Also fixes the weird PHP warnings about undefined array key.
(lower)
(Code cleanup. Also fixes the weird PHP warnings about undefined array key.)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<includeonly><onlyinclude>{{#lvardef:margin|{{#expr:0.01 * {{{size|40}}} }} }}{{#lvardef:size|{{{size|40}}} }}<span class="bg3wiki-itemicon-wrapper" {{#if:{{{no_padding|}}}||style="margin-left: {{#lvar:margin}}rem"}}>{{#cargo_query:
<includeonly>{{#lvardef: margin | {{#expr: 0.015 * {{{size|40}}} }} }}{{#lvardef: size | {{{size|40}}} }}<span class="bg3wiki-itemicon-wrapper {{#if:{{{wrap|}}}|wrap|nowrap}}" 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('', '{{#lvar:size}}'),LOWER(rarity),CONCAT('', '{{{show_rarity|}}}'),CONCAT('', "{{{name}}}")
|{{#cargo_query:
|where=item_icon._pageName="{{{name}}}"
  tables = item_icon
|limit=1
  | fields =
|order by=item_icon._pageName
    TRIM(icon) = icon,
|default={{ItemIcon Internal|{{{name}}} Item Icon.png|{{#lvar:size}}|common| true|{{{name}}}|missing=true}}
    CONCAT('', '{{#lvar:size}}') = size,
|more results text=
    LOWER(rarity) = rarity,
|format=template
    CONCAT('', '{{{show_rarity|}}}') = show_rarity,
|template=ItemIcon Internal
    CONCAT('', "{{{name}}}") = name
}} <span class="bg3wiki-itemicon-link" style="margin-left: {{#lvar:margin}}rem">{{#if:{{{show_name|}}}|[[{{{name}}}]] }}</span></span></onlyinclude></includeonly><noinclude>
  | where = {{#if: {{{uid|}}} | item_icon.uid = "{{{uid}}}" | item_icon._pageName="{{{name}}}" }}
 
  | limit = 1
{{/doc}}
  | order by = item_icon._pageName
 
  | default = {{ItemIcon Internal|{{{name}}} Unfaded Icon.png|{{#lvar:size}}|common| true|{{{name}}}|missing=true}}
<!-- Cargo table definition -->
  | more results text =
{{#cargo_declare:
  | format = template
_table = item_icon
  | template = ItemIcon Internal
|rarity = String (allowed values=common,uncommon,rare, very rare,legendary,story)
|icon = File
}}
}}
}}{{#if:{{{show_name|}}}|<span class="bg3wiki-itemicon-link" style="margin-left: 1ch">[[{{{name}}}{{#if:{{{alias|}}}|{{!}}{{{alias}}}}}]]</span>}}</span></includeonly><noinclude>{{/doc}}


== Template Data Section ==
== Template Data Section ==
Line 26: Line 25:
"params": {
"params": {
"size": {
"size": {
"description": "The height of the item icon. Optional.",
"description": "The height of the item icon.",
"suggestedvalues": [
"suggestedvalues": [
"40",
"40",
Line 42: Line 41:
},
},
"show_name": {
"show_name": {
"description": "Whether to link the icon as well. Optional. Providing any value at all will be interpreted as \"yes\".",
"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"
"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"
}
}
},
},
Line 49: Line 75:
"paramOrder": [
"paramOrder": [
"name",
"name",
"uid",
"size",
"size",
"show_name"
"show_name",
"no_padding",
"show_rarity",
"override_icon",
"override_rarity",
"alias",
"wrap"
],
],
"format": "inline"
"format": "inline"
}
}
</templatedata></noinclude>
</templatedata></noinclude>

Navigation menu