Template:Item icon: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
m (mention ItemIcon Insert)
(wrap by default, unless specifying nowrap. This matches Template:IconLink)
 
(39 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. Use [[Template:ItemIcon Insert]] to add a page that doesn't use [[Template:MiscItemPage]], [[Template:EquipmentPage]], or [[Template:WeaponPage]].
== 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>

Latest revision as of 22:49, 11 October 2024

This text is transcluded from Template:Item icon/doc.

This template fetches and displays an icon for an item. The information is uploaded using the standard item descriptions. Use Template:ItemIcon Insert to add a page that doesn't use Template:MiscItemPage, Template:EquipmentPage, or Template:WeaponPage.

Usage:
{{ItemIcon
|name=the name of the icon page
|uid=(optional) If specified, will search for this UID instead of the page name.
|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.
|show_rarity=(optional) Whether to add a border and background to the icon according to the item's rarity. Omit to not show it.
|no_padding=(optional) If specified, does not insert margin to the left and right of the ItemIcon. Recommended for use in tables, lists, and start of paragraphs.
|override_icon=(optional) If specified, skips looking up the Cargo table and inserts the specified icon directly. Must also specify '''override_rarity'''.
|override_rarity=(optional) When specified with '''override_icon''', will set the rarity of the displayed item.
|alias=(optional) If specified, the link text will be this instead.
|nowrap=(optional) If specified, the text will not wrap.
}}

Templates

Copy-ready template (no item name): {{ItemIcon|name=}}

Copy-ready template (with item name): {{ItemIcon|name=|show_name=true}}

Examples

ResultSizeShow name?Rarity?Code
Icon only

40 {{ItemIcon|name=Potion of Healing|size=40|show_name=|show_rarity=}}

25 {{ItemIcon|name=Potion of Healing|size=25|show_name=|show_rarity=}}

40 {{ItemIcon|name=Potion of Supreme Healing|size=40|show_name=|show_rarity=}}

25 {{ItemIcon|name=Potion of Supreme Healing|size=25|show_name=|show_rarity=}}

File:The Red Knight's Final Stratagem Unfaded Icon.png

40 {{ItemIcon|name=The Red Knight's Final Stratagem|size=40|show_name=|show_rarity=}}

File:The Red Knight's Final Stratagem Unfaded Icon.png

25 {{ItemIcon|name=The Red Knight's Final Stratagem|size=25|show_name=|show_rarity=}}
Linked icon

Potion of Healing

40 true {{ItemIcon|name=Potion of Healing|size=40|show_name=true|show_rarity=}}

Potion of Healing

25 true {{ItemIcon|name=Potion of Healing|size=25|show_name=true|show_rarity=}}

Potion of Supreme Healing

40 true {{ItemIcon|name=Potion of Supreme Healing|size=40|show_name=true|show_rarity=}}

Potion of Supreme Healing

25 true {{ItemIcon|name=Potion of Supreme Healing|size=25|show_name=true|show_rarity=}}

File:The Red Knight's Final Stratagem Unfaded Icon.pngThe Red Knight's Final Stratagem

40 true {{ItemIcon|name=The Red Knight's Final Stratagem|size=40|show_name=true|show_rarity=}}

File:The Red Knight's Final Stratagem Unfaded Icon.pngThe Red Knight's Final Stratagem

25 true {{ItemIcon|name=The Red Knight's Final Stratagem|size=25|show_name=true|show_rarity=}}
Rarity icon

Potion of Healing

40 true true {{ItemIcon|name=Potion of Healing|size=40|show_name=true|show_rarity=true}}

Potion of Healing

25 true true {{ItemIcon|name=Potion of Healing|size=25|show_name=true|show_rarity=true}}

Potion of Supreme Healing

40 true true {{ItemIcon|name=Potion of Supreme Healing|size=40|show_name=true|show_rarity=true}}

Potion of Supreme Healing

25 true true {{ItemIcon|name=Potion of Supreme Healing|size=25|show_name=true|show_rarity=true}}

File:The Red Knight's Final Stratagem Unfaded Icon.pngThe Red Knight's Final Stratagem

40 true true {{ItemIcon|name=The Red Knight's Final Stratagem|size=40|show_name=true|show_rarity=true}}

File:The Red Knight's Final Stratagem Unfaded Icon.pngThe Red Knight's Final Stratagem

25 true true {{ItemIcon|name=The Red Knight's Final Stratagem|size=25|show_name=true|show_rarity=true}}
Other

File:Missing Item Or Item Icon Unfaded Icon.pngMissing Item Or Item Icon

40 true true {{ItemIcon|name=Missing Item Or Item Icon|size=40|show_name=true|show_rarity=true}}

File:Missing Item Or Item Icon Unfaded Icon.pngMissing Item Or Item Icon

25 true true {{ItemIcon|name=Missing Item Or Item Icon|size=25|show_name=true|show_rarity=true}}
The Joltshooter{{ItemIcon|override_icon=Pig's Head Item Icon.png|name=The Joltshooter|override_rarity=legendary|show_name=true|show_rarity=true}}

File:Template:ItemIcon/Item Missing Images Unfaded Icon.pngTemplate:ItemIcon/Item Missing Images

40 true true {{ItemIcon|name=Template:ItemIcon/Item Missing Images|size=40|show_name=true|show_rarity=true}}
An alias{{ItemIcon|name=The Joltshooter|alias=An alias|show_name=true|show_rarity=true}}

In-text

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin tristique ligula vitae turpis varius ullamcorper. Ut sagittis Potion of Supreme Healing eu dolor accumsan venenatis. Maecenas sit amet ante at ligula efficitur fermentum. Suspendisse ac neque pretium nisi finibus euismod. Suspendisse varius ipsum lorem, vitae consectetur metus mattis sit amet. Proin ornare orci turpis, non blandit lorem scelerisque a. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Titanstring Bow in luctus arcu. Proin aliquet lorem quis lacus lacinia molestie. Suspendisse iaculis venenatis nibh, et dapibus augue varius a.

Wrap override

A is for Azuth, and other Gods IIA is for Azuth, and other Gods IIA is for Azuth, and other Gods IIA is for Azuth, and other Gods IIA is for Azuth, and other Gods IIA is for Azuth, and other Gods IIA is for Azuth, and other Gods II

UID search

Specifying the uid parameter allows for picking a specific item among a number of different items with the same name. Note that you must provide the name of the item for it to display properly.

* {{ItemIcon|name=Leather Armour|show_name=true}}
* {{ItemIcon|name=Leather Armour|uid=ARM_Leather_Rogue|show_name=true}}
* {{ItemIcon|name=Leather Armour|uid=UNI_Leather_Jaheira|show_name=true}}

Related templates

Transcluded from Template:ItemIcon/Family.

Template:ItemIcon

The base ItemIcon with all functionality.


Template:SmItemIcon

A version of ItemIcon that always has a image height of 25px and links the item.

Potion of Superior Healing

Template:MdItemIcon

A version of ItemIcon that always has a image height of 30px and links the item.

Potion of Superior Healing

Template:LgItemIcon

A version of ItemIcon that always has an image height of 40px and links the item.

Potion of Supreme Healing


Template:RarityItem

A version of ItemIcon that displays the rarity colors and links the item. Defaults to 25px but can be adjusted.

The Joltshooter


Template:SmRarityItem

A version of RarityItem that defaults to 20px instead of 25. For use in running texts.

The Joltshooter

Template:MdRarityItem

A version of RarityItem that defaults to 30px instead of 25. For use on Template:ActionPage, which specifically needs to be passed a template name.

The Joltshooter

Template:LgRarityItem

A version of RarityItem that defaults to 40px instead of 25. For use on various list pages.

The Joltshooter


Template:ItemIcon Insert

A utility template that inserts information into the "item_icon" table, which is where all information used to provide ItemIcon functionality is stored. This template should only need to be manually called for pages that are not items, but might want to have an icon associated with them, for example Food Supply Table 4.

Troubleshooting

Icon does not show up

  • Check that the name is provided correctly.
Refer to the template you are using. Template:ItemIcon requires the name to be provided as the name= parameter, while other templates might use anonymous parameters.
  • Check that the page exists
The page must exist and use Template:MiscItemPage, Template:EquipmentPage, Template:WeaponPage, or Template:ItemIcon Insert. Technically, you could also insert directly into the item_icon Cargo table, but please don't do that without good reason.
Also make sure that the item is spelled correctly. ItemIcon is unaware of redirects, which can cause a missing icon link when the page link works fine.
  • Check that the parameters are passed to the page-generating templates
ItemIcon pulls from the page-generating template parameters, particularly rarity, image, and icon. Either image or icon needs to be set for an icon to show.
  • Try doing a null edit on the page.
The ItemIcon template was introduced after the page-generating templates. This means that information won't be inserted into the Cargo table until the pages that use the page-generating templates are edited. You can do a null edit to forcibly insert information into the table. This is an edit where you change nothing. It will not show up in the page's edit history or your contribution page, but it will refresh the page and, if applicable, insert the info needed into the table.
  • Ask on Discord
If none of the above steps work, ask on the Discord and someone might be able to help solve the problem.

Template Data Section

Inserts an item's icon automatically. Can also display a link to the item.

Template parameters

This template prefers inline formatting of parameters.

ParameterDescriptionTypeStatus
namename

The name of the icon. Identical to the item's page name.

Example
Potion of Healing
Page namerequired
uiduid

If specified, will instead search by UID.

Stringoptional
sizesize

The height of the item icon.

Suggested values
40 25 20
Default
40
Numberoptional
show_nameshow_name

If non-empty, will link the icon as well.

Booleanoptional
no_paddingno_padding

Whether to remove exterior padding. Advanced use.

Unknownoptional
show_rarityshow_rarity

If non-empty, will display an icon border corresponding to the rarity.

Booleanoptional
override_iconoverride_icon

If provided, will override the icon with the provided one.

Stringoptional
override_rarityoverride_rarity

If provided, will replace the fetched rarity.

Stringoptional
aliasalias

An alias for the item.

Stringoptional
wrapwrap

If non-empty, will allow the item icon to wrap.

Booleanoptional