Difference between revisions of "Template:Card table"
(Add an ID to the first transclusion of this on a page) |
Dinoguy1000 (talk | contribs) (add DEFAULTSORT code (mostly ganked from the code in {{CardTable2}}; let's hope none of the modifications are wrong >_> )) |
||
Line 113: | Line 113: | ||
</div> | </div> | ||
{{ #if: {{{below<includeonly>|</includeonly>}}} | <div class="below {{{belowclass|}}}">{{{below}}}</div> }} | {{ #if: {{{below<includeonly>|</includeonly>}}} | <div class="below {{{belowclass|}}}">{{{below}}}</div> }} | ||
− | </div>{{ | + | </div>{{<!-- sortkey when desired --> |
+ | #if: {{ #var: $defaultsort }}<!-- don't bother with any of this if we've already set DEFAULTSORT --> | ||
+ | || {{ #if: {{{defaultsort|}}}<!-- parameter overrides automatic sortkey --> | ||
+ | | {{ #vardefine: $defaultsort | {{{defaultsort}}} }} | ||
+ | | {{ #vardefine: $ds-pagename | {{Normalized pagename}} }}{{ #vardefine: $defaultsort | ||
+ | | {{ #ifeq: {{ #explode: {{ #var: $ds-pagename }} }} | A <!-- cards whose name starts with the article "A" --> | ||
+ | | {{ #sub: {{ #var: $ds-pagename }} | 2 }} | ||
+ | | {{ #ifeq: {{ #explode: {{ #var: $ds-pagename }} }} | An <!-- cards whose name starts with the article "An" --> | ||
+ | | {{ #sub: {{ #var: $ds-pagename }} | 3 }} | ||
+ | | {{ #ifeq: {{ #explode: {{ #var: $ds-pagename }} }} | The <!-- cards whose name starts with the article "The" --> | ||
+ | | {{ #if: {{ #pos: {{ #var: $ds-pagename }} | The Agent }}{{ #pos: {{ #var: $ds-pagename }} | The Fabled }} | ||
+ | | none <!-- ...except for "The Agent" and "The Fabled" cards --> | ||
+ | | {{ #sub: {{ #var: $ds-pagename }} | 4 }} | ||
+ | }} | ||
+ | | {{ <!-- now make Number cards use natural sorting order --> | ||
+ | #if: {{and|{{ #ifeq: {{ #explode: {{ #var: $ds-pagename }} }} | Number | 1 }}|{{ #pos: {{ #var: $ds-pagename }} | : }}}} | ||
+ | | Number {{ #if: {{ #pos: {{ #var: $ds-pagename }} | Number C }} | ||
+ | | C{{ padleft: {{ #replace: {{ #explode: {{ #var: $ds-pagename }} || 1 }} | C }} | 4 | 0 }} | ||
+ | | {{ padleft: {{ #explode: {{ #var: $ds-pagename }} || 1 }} | 4 | 0 }} | ||
+ | }}{{ #explode: {{ #var: $ds-pagename }} | : | 1 }} | ||
+ | | none | ||
+ | }} | ||
+ | }} | ||
+ | }} | ||
+ | }} | ||
+ | }} | ||
+ | }}{{ #ifeq: {{ #var: $defaultsort }} | none || {{DEFAULTSORT:{{ #var: $defaultsort }}}} }} | ||
+ | }}{{ | ||
#if: {{NAMESPACE}} | #if: {{NAMESPACE}} | ||
| <!-- non-mainspace categories here -->{{ | | <!-- non-mainspace categories here -->{{ |
Revision as of 21:38, 31 January 2015
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}}} }}