Difference between revisions of "Template:Card table"
Dinoguy1000 (talk | contribs) (these vars need to be named more carefully to avoid the possibility of collisions with variables set by the wrapper card templates or other templates) |
Dinoguy1000 (talk | contribs) (shorter var names; don't set any categories or properties unless it's the first transclusion; better image width handling (among other things, don't stretch images smaller than the max width unless their width is explicitly set)) |
||
Line 1: | Line 1: | ||
{{ #if: {{{header16|}}}{{{headerstyle16|}}}{{{label16|}}}{{{labelstyle16|}}}{{{data16|}}}{{{datastyle16|}}}{{{class16|}}}{{{rowclass16|}}} | {{ #if: {{{header16|}}}{{{headerstyle16|}}}{{{label16|}}}{{{labelstyle16|}}}{{{data16|}}}{{{datastyle16|}}}{{{class16|}}}{{{rowclass16|}}} | ||
| <div class="error">Error: too many rows!</div>[[Category:Card table transclusions with too many rows]] | | <div class="error">Error: too many rows!</div>[[Category:Card table transclusions with too many rows]] | ||
− | }}{{ # | + | }}{{ #if: {{{image_raw|}}} || {{ #vardefine: $ct_img | {{ #if: {{{image|}}} | {{PAGENAME:{{{image}}}}} | Back-EN.png }} |
− | }}{{ #vardefine: $ | + | }}{{ #vardefine: $ct_max_width | {{px|{{{max_width}}}}} |
− | }}{{ #if: {{{image_right|}}} | + | }}{{ #vardefine: $ct_max_width | {{ #iferror: {{ #ifexpr: {{ #var: $ct_max_width }} > 400 | 400 | {{ #var: $ct_max_width }} }} | 200 }} |
− | | {{ #vardefine: $ | + | }}{{ #vardefine: $ct_width | {{px|{{{width}}}}} |
− | + | }}{{ #vardefine: $ct_width | {{ #iferror: {{ #expr: {{ #var: $ct_width }} }} | {{ #imgw: {{ #var: $ct_img }} }} | {{ #var: $ct_width }} }} | |
+ | }}{{ #vardefine: $ct_width | {{ #ifexpr: {{ #var: $ct_width }} < {{ #var: $ct_max_width }} | {{ #var: $ct_width }} | {{ #var: $ct_max_width }} }} | ||
+ | }}{{ #if: {{{image_right|}}} | ||
+ | | {{ #vardefine: $ct_img_right | {{PAGENAME:{{{image_right}}}}} | ||
+ | }}{{ #vardefine: $ct_max_width_right | {{px|{{{max_width_right}}}}} | ||
+ | }}{{ #vardefine: $ct_max_width_right | {{ #iferror: {{ #ifexpr: {{ #var: $ct_max_width_right }} > 400 | 400 | {{ #var: $ct_max_width_right }} }} | 200 }} | ||
+ | }}{{ #vardefine: $ct_width_right | {{px|{{{width_right}}}}} | ||
+ | }}{{ #vardefine: $ct_width_right | {{ #iferror: {{ #expr: {{ #var: $ct_width_right }} }} | {{ #imgw: {{ #var: $ct_img_right }} }} | {{ #var: $ct_width_right }} }} | ||
+ | }}{{ #vardefine: $ct_width_right | {{ #ifexpr: {{ #var: $ct_width_right }} < {{ #var: $ct_max_width_right }} | {{ #var: $ct_width_right }} | {{ #var: $ct_max_width_right }} }} | ||
+ | }} | ||
}} | }} | ||
}}<!-- | }}<!-- | ||
− | --><div {{ #if: {{ #var: $first-card-table }} || id="main-card-table" | + | --><div {{ #if: {{ #var: $first-card-table }} || id="main-card-table" }} class="card-table {{ #if: {{{bodyclass|}}} | {{{bodyclass}}} | blank-card }}" style="{{{bodystyle|}}}"> |
{{ #if: {{{title<includeonly>|</includeonly>}}} | | {{ #if: {{{title<includeonly>|</includeonly>}}} | | ||
<div class="heading {{{titleclass|}}}" style="{{{titlestyle|}}}"><div>{{{title}}}</div></div> | <div class="heading {{{titleclass|}}}" style="{{{titlestyle|}}}"><div>{{{title}}}</div></div> | ||
Line 16: | Line 25: | ||
<div class="imagecolumn">{{ #if: {{{image_raw|}}} | <div class="imagecolumn">{{ #if: {{{image_raw|}}} | ||
| {{{image_raw}}} | | {{{image_raw}}} | ||
− | | [[File:{{ # | + | | [[File:{{ #var: $ct_img }}|link=File:{{ #var: $ct_img }}|{{ #var: $ct_width }}px]]{{ #if: {{{image_right|}}} |
− | | [[File:{{ | + | | [[File:{{ #var: $ct_img_right }}|link=File:{{ #var: $ct_img_right }}|{{ #var: $ct_width_right }}px]] |
}} | }} | ||
}}{{ #if: {{{below_image<includeonly>|</includeonly>}}} | <div class="belowimage hlist"> | }}{{ #if: {{{below_image<includeonly>|</includeonly>}}} | <div class="belowimage hlist"> | ||
Line 137: | Line 146: | ||
}} | }} | ||
}}{{ #ifeq: {{ #var: $defaultsort }} | none || {{DEFAULTSORT:{{ #var: $defaultsort }}}} }} | }}{{ #ifeq: {{ #var: $defaultsort }} | none || {{DEFAULTSORT:{{ #var: $defaultsort }}}} }} | ||
− | }}{{ #if: {{NAMESPACE}} | + | }}{{ #if: {{ #var: $first_card_table }}<!-- only add categories/properties on the first transclusion --> |
− | + | || {{ #if: {{NAMESPACE}} | |
− | + | | <!-- non-mainspace categories here -->{{ #ifeq: {{ns:template}}:{{BASEPAGENAME}} | {{FULLPAGENAME}} | [[Category:Card table templates]] }} | |
− | + | | {{ #ifexist: Card Gallery:{{ #var: $main | {{Normalized pagename|{{PAGENAME}}}} }} | |
− | + | || [[Category:Cards that need a gallery]] | |
− | }}<noinclude>{{Documentation}}</noinclude> | + | }}[[Page name::{{FULLPAGENAME}}| ]][[Page type::Card page| ]] |
+ | }} | ||
+ | }}{{ #vardefine: $first_card_table | 1 }}<noinclude>{{Documentation}}</noinclude> |
Revision as of 18:34, 30 June 2016
This template uses Lua: |
{{Card table}} is a metatemplate used to create card table templates.
Usage
Example
{{Card table | title = {{ #if: {{{title|}}} | {{{title}}} | {{PAGENAME}} }} | image = {{ #if: {{{image|}}} | {{{image}}} | Back-EN.png }} | label1 = [[Attribute]] | data1 = [[{{uc:{{{attribute}}}}}]] [[File:{{uc:{{{attribute}}}}}.svg|25px|alt=]] | label2 = [[Level]] | data2 = {{{level}}} {{Repeat|[[File:CG Star.svg|18px|alt=]]|{{{level}}}}} | label3 = [[Type|Type(s)]] | data3 = {{Card table/types|{{{types}}}|{{{effect_types|}}}|linked}} | label4 = [[ATK]]/[[DEF]] | data4 = {{{atk}}}/{{{def}}} | data5 = <div class="lore">{{{lore}}}</div> | label6 = Effect types | data6 = {{{effect types|}}} | label7 = Status | data7 = {{{status}}} }}