Difference between revisions of "Template:ValuableTable/row"

From Stoneshard wiki
Jump to navigation Jump to search
(Add image variants handling. Still needs image display & collapse fix.)
(Test Fix image limiting because of "#ifeq" in excess. Add vardefine for item link. Add loop for variants. New problem, 2 extra spaces between name and image.)
Line 10: Line 10:
     --- Load translations that are used multiple times into variables. ---
     --- Load translations that are used multiple times into variables. ---
     -->{{#vardefine:TranslateName|{{Translate|{{{1}}}|ValuableNames}}}}
     -->{{#vardefine:TranslateName|{{Translate|{{{1}}}|ValuableNames}}}}
     |- <!-- Starts a new table row. [Image inside row]-->
     <!-- Define "Link" var, with a subpage verification. If subpagename = pagename, we are not on a subpage, therefore URL becomes "item name". If we are on a subpage, URL becomes "item name/subgpagename". Used for other languages.-->
    <!-- Check if we are on a subpage. If subpagename = pagename, we are not on a subpage, therefore URL becomes "item name". If we are on a subpage, URL becomes "item name/subgpagename". Used for other languages. ---
     {{#vardefine:Link|{{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}}}
     -->| '''[[{{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}|<!--
    |- <!-- Starts a new table row. [Image(s) & Name inside row]-->
    --- Check if item name has a translation. If yes, load translation of item name. If not, return empty string. Used for other languages. ---
     <!-- Display image variants -->
     -->{{#if:{{#var:TranslateName}}|{{#var:TranslateName}}}}]]'''<!--
    | '''[[{{#var:Link}}|{{#if:{{#var:TranslateName}}|{{#var:TranslateName}}|{{{1}}}}}]]'''<!--
     -->
     -->{{#vardefine:Images|}}
    <!-- Display the image(s) -->
     {{#ifexist:File:{{#var:ImageBase}} A.png|
     {{#ifexist:File:{{#var:ImageBase}} A.png|<!-- If variant images exist -->
         {{#vardefine:Images|{{#var:Images}} [[File:{{#var:ImageBase}} A.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#var:Link}}]]}}
        <!-- Display each variant -->
    }}
         [[File:{{#var:ImageBase}} A.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}]]
    {{#ifexist:File:{{#var:ImageBase}} B.png|
        {{#ifexist:File:{{#var:ImageBase}} B.png|[[File:{{#var:ImageBase}} B.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}]]}}
        {{#vardefine:Images|{{#var:Images}} [[File:{{#var:ImageBase}} B.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#var:Link}}]]}}
        {{#ifexist:File:{{#var:ImageBase}} C.png|[[File:{{#var:ImageBase}} C.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}]]}}
    }}
        {{#ifexist:File:{{#var:ImageBase}} D.png|[[File:{{#var:ImageBase}} D.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}]]}}
    {{#ifexist:File:{{#var:ImageBase}} C.png|
    |<!-- Otherwise, display the base image -->
        {{#vardefine:Images|{{#var:Images}} [[File:{{#var:ImageBase}} C.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#var:Link}}]]}}
         {{#ifexist:File:{{#var:ImageBase}}.png|[[File:{{#var:ImageBase}}.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#ifeq:{{SUBPAGENAME}}|{{PAGENAME}}|{{{1}}}|{{{1}}}/{{SUBPAGENAME}}}}]]}}
    }}
    {{#ifexist:File:{{#var:ImageBase}} D.png|
        {{#vardefine:Images|{{#var:Images}} [[File:{{#var:ImageBase}} D.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#var:Link}}]]}}
    }}
    {{#if:{{#var:Images}}|{{#var:Images}}|<!-- Otherwise, display base image -->
         {{#ifexist:File:{{#var:ImageBase}}.png|
            [[File:{{#var:ImageBase}}.png|center|alt={{#var:TranslateName}}|class=image2x|link={{#var:Link}}]]
        }}
     }}
     }}
     <!-- Display the rest of the data in the row -->
     <!-- Display the rest of the data in the row -->

Revision as of 23:48, 19 January 2025

Template-info.png Documentation

This article is a stub. You can help Stoneshard wiki by expanding it.

This Template replicates the logic used for the Template:WeaponTable/row.

Syntax

{{ValuableTable/row|Agate}}

Usage

It should be used with a 'header', right before it.
{{ValuableTable/head}}
{{ValuableTable/row|Agate}}.

Any Valuables added in Valuable Data, can be used with the '/row' template.

Debug

For future modifications or debugging, you can add this, after the "ItemDescription" variable (Open Source to verify code):

   [...]
   |{{{1}}}
   Base Image: 
   Variants: 
   Datastring: 

Examples

Single Image

Item Inv. Slots Price Gold Icon Description


Agate



1×1 50 Gold.png Common folk believe agate to bring good luck. It's often used to make cheap jewelry.


Multiple Images

Item Inv. Slots Price Gold Icon Description


Horse Pelt



2×3 60 Gold.png Peasants only kill horses that are hopelessly sick or already half-dead from old age.



Rabbit Pelt



1×2 40-50 Gold.png Despite how cautious and skittish rabbits can be, hunting one down isn't that hard. Their pelts are usually used to make clothes.