Permanently protected template

Difference between revisions of "Template:Card table"

From Yugipedia
Jump to: navigation, search
(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)
(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]]
}}{{ #vardefine: $template:card-table_max_width | {{ #iferror: {{ #ifexpr: {{px|{{{max_width}}}}} > 400 | 400 | {{px|{{{max_width}}}}} }} | 200 }}
+
}}{{ #if: {{{image_raw|}}} || {{ #vardefine: $ct_img | {{ #if: {{{image|}}} | {{PAGENAME:{{{image}}}}} | Back-EN.png }}
}}{{ #vardefine: $template:card-table_width     | {{ #iferror: {{ #ifexpr: {{px|{{{width}}}}} < {{ #var: $template:card-table_max_width }} | {{px|{{{width}}}}} | {{ #var: $template:card-table_max_width }} }} | {{ #var: $template:card-table_max_width }} }}
+
  }}{{ #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: $template:card-table_max_width_right | {{ #iferror: {{ #ifexpr: {{px|{{{max_width_right}}}}} > 400 | 400 | {{px|{{{max_width_right}}}}} }} | 200 }}
+
  }}{{ #vardefine: $ct_width    | {{px|{{{width}}}}}
  }}{{ #vardefine: $template:card-table_width_right  | {{ #iferror: {{ #ifexpr: {{px|{{{width_right}}}}} < {{ #var: $template:card-table_max_width_right }} | {{px|{{{width_right}}}}} | {{ #var: $template:card-table_max_width_right }} }} | {{ #var: $template:card-table_max_width_right }} }}
+
  }}{{ #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" {{ #vardefine: $first-card-table | 1 }} }} class="card-table {{ #if: {{{bodyclass|}}} | {{{bodyclass}}} | blank-card }}" style="{{{bodystyle|}}}">
+
--><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:{{ #if: {{{image|}}} | {{{image}}} | Back-EN.png }}|link=File:{{ #if: {{{image|}}} | {{{image}}} | Back-EN.png }}|{{ #var: $template:card-table_width }}px]]{{ #if: {{{image_right|}}}
+
   | [[File:{{ #var: $ct_img }}|link=File:{{ #var: $ct_img }}|{{ #var: $ct_width }}px]]{{ #if: {{{image_right|}}}
     | [[File:{{{image_right|}}}|link=File:{{{image_right|}}}|{{ #var: $template:card-table_width_right }}px]]
+
     | [[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 -->
  | <!-- non-mainspace categories here -->{{ #ifeq: {{ns:template}}:{{BASEPAGENAME}} | {{FULLPAGENAME}} | [[Category:Card table templates]] }}
+
  || {{ #if: {{NAMESPACE}}
  | {{ #ifexist: Card Gallery:{{ #var: $main | {{Normalized pagename|{{PAGENAME}}}} }}
+
    | <!-- non-mainspace categories here -->{{ #ifeq: {{ns:template}}:{{BASEPAGENAME}} | {{FULLPAGENAME}} | [[Category:Card table templates]] }}
    || [[Category:Cards that need a gallery]]
+
    | {{ #ifexist: Card Gallery:{{ #var: $main | {{Normalized pagename|{{PAGENAME}}}} }}
  }}[[Page name::{{FULLPAGENAME}}| ]][[Page type::Card page| ]]
+
      || [[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

{{{title}}}
{{{above}}}
Back-EN.png
{{{below_image}}}
{{{below}}}