Template:Infobox

(Difference between revisions)

(updated template)
 
Line 1: Line 1:
<noinclude><!-- Specify row colours at "Template:Rowbg" and "Template:Rowbg-alt" -->
+
<noinclude>[[Category:Templates]]</noinclude>
  
 
To use this template, type the following into a page:
 
To use this template, type the following into a page:
  
<pre>{{Infobox
+
<pre>
 
+
{{Infobox
|title =
+
|title = Example Infobox
|image = [[Image:*.png|300px]]
+
|image = [[File:*.png|300px]]
 
|imagecaption =
 
|imagecaption =
 
+
|rows =
|label1 =  
+
@@ label1 = data1
|data1 =
+
@@ label2 = data2
|label2 =  
+
@@ label3 = data3
|data2 =
+
@@ label4 = data4
 
+
 
}}
 
}}
 
</pre>
 
</pre>
  
All initial elements are optional, but at least one must be specified for each "row". This template supports up to forty different entries.
+
This template supports up to forty different, optional entries. It is backwards compatible for the syntaxes in Infobox 1.0 through 3.5, and it does not depend on a /Row template. However, it does require [[Template:!]].
  
<table id="infobox" cellspacing="0" cellpadding="3">
+
{{Infobox
<!-- Header --><tr style="background:#{{Rowbg}};"><th colspan="2" style="font-size:110%; text-align: center;"><i>Title</i></th></tr><tr style="background:#{{Rowbg}};"><td colspan="2" style="text-align: center;">'''Image'''<br />Image caption</tr>
+
|title = Example Infobox
<!-- Row 1 --><tr style="background:#{{Rowbg}};"><td><b>Label 1</b></td><td>Data 1</td></tr>
+
|image = [[File:*.png|300px]]
<!-- Row 2 --><tr style="background:#{{Rowbg-alt}};"><td><b>Label 2</b></td><td>Data 2</td></tr>
+
|imagecaption =
<!-- Row 3 --><tr style="background:#{{Rowbg}};"><td><b>Label 3</b></td><td>Data 3</td></tr>
+
|rows =
<!-- Row 4 --><tr style="background:#{{Rowbg-alt}};"><td><b>Label 4</b></td><td>Data 4</td></tr>
+
@@ label1 = data1
</table>
+
@@ label2 = data2
</noinclude><includeonly><table style="float: right; width: 300px; font-size: 90%; text-align: left; padding-left: 1em; margin-bottom: 1em;" cellspacing="0" cellpadding="3"><!-- Header --><tr style="background:#{{Rowbg}}"><th colspan="2" style="font-size:110%; text-align: center;"><i>{{{title}}}</i></th></tr><tr style="background:#{{Rowbg}}"><td colspan="2" style="text-align: center;">{{{image}}}{{{imagecaption}}}</tr>{{ #if: {{{label1|}}} | <!-- Row 1 --><tr style="background:#{{Rowbg}}"><td><b>{{{label1}}}</b></td><td>{{{data1}}}</td></tr> }}{{ #if: {{{label2|}}} | <!-- Row 2 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label2}}}</b></td><td>{{{data2}}}</td></tr> }}{{ #if: {{{label3|}}} | <!-- Row 3 --><tr style="background:#{{Rowbg}}"><td><b>{{{label3}}}</b></td><td>{{{data3}}}</td></tr> }}{{ #if: {{{label4|}}} | <!-- Row 4 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label4}}}</b></td><td>{{{data4}}}</td></tr> }}{{ #if: {{{label5|}}} | <!-- Row 5 --><tr style="background:#{{Rowbg}}"><td><b>{{{label5}}}</b></td><td>{{{data5}}}</td></tr> }}{{ #if: {{{label6|}}} | <!-- Row 6 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label6}}}</b></td><td>{{{data6}}}</td></tr> }}{{ #if: {{{label7|}}} | <!-- Row 7 --><tr style="background:#{{Rowbg}}"><td><b>{{{label7}}}</b></td><td>{{{data7}}}</td></tr> }}{{ #if: {{{label8|}}} | <!-- Row 8 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label8}}}</b></td><td>{{{data8}}}</td></tr> }}{{ #if: {{{label9|}}} | <!-- Row 9 --><tr style="background:#{{Rowbg}}"><td><b>{{{label9}}}</b></td><td>{{{data9}}}</td></tr> }}{{ #if: {{{label10|}}} | <!-- Row 10 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label10}}}</b></td><td>{{{data10}}}</td></tr> }}{{ #if: {{{label11|}}} | <!-- Row 11 --><tr style="background:#{{Rowbg}}"><td><b>{{{label11}}}</b></td><td>{{{data11}}}</td></tr> }}{{ #if: {{{label12|}}} | <!-- Row 12 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label12}}}</b></td><td>{{{data12}}}</td></tr> }}{{ #if: {{{label13|}}} | <!-- Row 13 --><tr style="background:#{{Rowbg}}"><td><b>{{{label13}}}</b></td><td>{{{data13}}}</td></tr> }}{{ #if: {{{label14|}}} | <!-- Row 14 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label14}}}</b></td><td>{{{data14}}}</td></tr> }}{{ #if: {{{label15|}}} | <!-- Row 15 --><tr style="background:#{{Rowbg}}"><td><b>{{{label15}}}</b></td><td>{{{data15}}}</td></tr> }}{{ #if: {{{label16|}}} | <!-- Row 16 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label16}}}</b></td><td>{{{data16}}}</td></tr> }}{{ #if: {{{label17|}}} | <!-- Row 17 --><tr style="background:#{{Rowbg}}"><td><b>{{{label17}}}</b></td><td>{{{data17}}}</td></tr> }}{{ #if: {{{label18|}}} | <!-- Row 18 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label18}}}</b></td><td>{{{data18}}}</td></tr> }}{{ #if: {{{label19|}}} | <!-- Row 19 --><tr style="background:#{{Rowbg}}"><td><b>{{{label19}}}</b></td><td>{{{data19}}}</td></tr> }}{{ #if: {{{label20|}}} | <!-- Row 20 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label20}}}</b></td><td>{{{data20}}}</td></tr> }}{{ #if: {{{label21|}}} | <!-- Row 21 --><tr style="background:#{{Rowbg}}"><td><b>{{{label21}}}</b></td><td>{{{data21}}}</td></tr> }}{{ #if: {{{label22|}}} | <!-- Row 22 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label22}}}</b></td><td>{{{data22}}}</td></tr> }}{{ #if: {{{label23|}}} | <!-- Row 23 --><tr style="background:#{{Rowbg}}"><td><b>{{{label23}}}</b></td><td>{{{data23}}}</td></tr> }}{{ #if: {{{label24|}}} | <!-- Row 24 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label24}}}</b></td><td>{{{data24}}}</td></tr> }}{{ #if: {{{label25|}}} | <!-- Row 25 --><tr style="background:#{{Rowbg}}"><td><b>{{{label25}}}</b></td><td>{{{data25}}}</td></tr> }}{{ #if: {{{label26|}}} | <!-- Row 26 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label26}}}</b></td><td>{{{data26}}}</td></tr> }}{{ #if: {{{label27|}}} | <!-- Row 27 --><tr style="background:#{{Rowbg}}"><td><b>{{{label27}}}</b></td><td>{{{data27}}}</td></tr> }}{{ #if: {{{label28|}}} | <!-- Row 28 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label28}}}</b></td><td>{{{data28}}}</td></tr> }}{{ #if: {{{label29|}}} | <!-- Row 29 --><tr style="background:#{{Rowbg}}"><td><b>{{{label29}}}</b></td><td>{{{data29}}}</td></tr> }}{{ #if: {{{label30|}}} | <!-- Row 30 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label30}}}</b></td><td>{{{data30}}}</td></tr> }}{{ #if: {{{label31|}}} | <!-- Row 31 --><tr style="background:#{{Rowbg}}"><td><b>{{{label31}}}</b></td><td>{{{data31}}}</td></tr> }}{{ #if: {{{label32|}}} | <!-- Row 32 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label32}}}</b></td><td>{{{data32}}}</td></tr> }}{{ #if: {{{label33|}}} | <!-- Row 33 --><tr style="background:#{{Rowbg}}"><td><b>{{{label33}}}</b></td><td>{{{data33}}}</td></tr> }}{{ #if: {{{label34|}}} | <!-- Row 34 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label34}}}</b></td><td>{{{data34}}}</td></tr> }}{{ #if: {{{label35|}}} | <!-- Row 35 --><tr style="background:#{{Rowbg}}"><td><b>{{{label35}}}</b></td><td>{{{data35}}}</td></tr> }}{{ #if: {{{label36|}}} | <!-- Row 36 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label36}}}</b></td><td>{{{data36}}}</td></tr> }}{{ #if: {{{label37|}}} | <!-- Row 37 --><tr style="background:#{{Rowbg}}"><td><b>{{{label37}}}</b></td><td>{{{data37}}}</td></tr> }}{{ #if: {{{label38|}}} | <!-- Row 38 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label38}}}</b></td><td>{{{data38}}}</td></tr> }}{{ #if: {{{label39|}}} | <!-- Row 39 --><tr style="background:#{{Rowbg}}"><td><b>{{{label39}}}</b></td><td>{{{data39}}}</td></tr> }}{{ #if: {{{label40|}}} | <!-- Row 40 --><tr style="background:#{{Rowbg-alt}};"><td><b>{{{label40}}}</b></td><td>{{{data40}}}</td></tr> }}</table></includeonly>
+
@@ label3 = data3
 +
@@ label4 = data4
 +
}}
 +
 
 +
<onlyinclude><includeonly>{| style="float:right; clear:right; width:300px; font-size:90%; text-align:left; margin:0 0 1em 1em;" cellspacing="0" cellpadding="3"
 +
{{!}}- style="background:{{Rowbg}}"
 +
! colspan="2" style="font-size:110%; font-style:italic;" {{!}} {{#if: {{{title|}}} | {{{title}}} | {{PageName}}}}
 +
{{!}}- style="background:{{Rowbg}}"
 +
{{!}} colspan="2" style="text-align:center;" {{!}} {{{image|}}}{{#if: {{{imagecaption|}}} | <br />{{{imagecaption}}} }}
 +
{{#vardefine: i | 1 }}{{#vardefine: max-rows | 40 }}{{#while:
 +
  | {{#ifexpr: {{#var:i}} <= {{#var:max-rows}} | true}}
 +
  | {{#vardefine: rowbg-color |
 +
      {{#ifexpr: {{#var:i}} mod 2 = 1
 +
        | {{Rowbg}}
 +
        | {{Rowbg-alt}}
 +
      }}
 +
    }}
 +
    {{#if: {{{rows|}}}
 +
      | <!-- 4.0 -->
 +
        {{#vardefine: row |
 +
          {{#explode: {{{rows}}} | @@ | {{#var:i}} }}
 +
        }}
 +
      | {{#vardefine: arg | {{{ {{#var:i}} |}}} }}
 +
        {{#if: {{#var:arg}}
 +
          | <!-- 3.0/2.0 -->
 +
            {{#vardefine: row |
 +
              {{#replace: {{#var:arg}} | :: | = }}
 +
            }}
 +
          | <!-- 1.0 -->
 +
            {{#if: {{{label{{#var:i}}|}}}
 +
              | {{#vardefine: row |
 +
                  {{{label{{#var:i}}|}}} {{#urldecode: %3D }} {{{data{{#var:i}}|}}}
 +
                }}
 +
              | {{#vardefine: row | }}
 +
            }}
 +
        }}
 +
    }}
 +
    {{#if: {{#vardefineecho: row | {{#replace: {{#var:row}} | \= | &#61;}} }}
 +
      | {{#ifexpr: {{#var:i}} > 1 | <nowiki/>}}
 +
        {{!}}- style="background:{{#var:rowbg-color}};"
 +
        {{!}} style="font-weight:bold;" {{!}} {{#sub: {{#var:row}} | 0 | {{#pos:{{#var:row}}|=}} }}
 +
        {{!}} {{#sub: {{#var:row}} | {{#expr: 1 + {{#pos:{{#var:row}}|=}} }} }}
 +
      | <!-- row doesn't exist; break loop -->
 +
        {{#vardefine: i | {{#expr: {{#var:max-rows}} + 1}} }}
 +
    }}
 +
    {{#vardefine: i | {{#expr: {{#var:i}} + 1 }} }}
 +
}}
 +
|}</includeonly></onlyinclude>

Latest revision as of 20:56, 8 December 2011


To use this template, type the following into a page:

{{Infobox
|title = Example Infobox
|image = [[File:*.png|300px]]
|imagecaption =
|rows =
@@ label1 = data1
@@ label2 = data2
@@ label3 = data3
@@ label4 = data4
}}

This template supports up to forty different, optional entries. It is backwards compatible for the syntaxes in Infobox 1.0 through 3.5, and it does not depend on a /Row template. However, it does require Template:!.

Example Infobox
300px
label1 data1
label2 data2
label3 data3
label4 data4