Template:Infobox/sandbox
This is the template sandbox page for Template:Infobox (diff). See also the companion subpage for test cases. |
This template uses Lua: |
{{Infobox}} is a meta-template: used to organise an actual {{Infobox sometopic}} template (like {{Infobox Version}}).
For [[Template:Infobox sometopic]]
, template code then looks like this, simplified:
{{Infobox
| title = {{{title|{{PAGENAME}}}}}
| image = {{{image|}}}
| caption1 = {{{caption|}}}
| label1 = Former names
| data1 = {{{former_names|}}}
| header2 = General information
| label3 = Status
| data3 = {{{status|}}}
... <!-- etc. -->
}}
Optional control parameters[edit source]
- nocat
- If this is set to "yes", the current page will not be autocategorized in a maintenance category when the generated infobox has some problems or no visible data section. Leave empty by default or set to "yes" to activate it.
Content parameters[edit source]
Title[edit source]
- title
- Text to put within the uppermost cell of the table.
Illustration images[edit source]
- image(n)
- images to display at the top of the template. Use full image syntax, for example [[File:example.png|200px|alt=Example alt text]].
- caption(n)
- Text to put underneath the images.
Main data[edit source]
- header(n)
- Text to use as a header in row n.
- label(n)
- Text to use as a label in row n.
- data(n)
- Text to display as data in row n.
Note: for any given value for (n), not all combinations of parameters are permitted. The presence of a |header(n)=
will cause the corresponding |data(n)=
(and |rowclass(n)=
|label(n)=
, see below) to be ignored; the absence of a |data(n)=
will cause the corresponding |label(n)=
to be ignored. Valid combinations for any single row are:
|class(n)=
|header(n)=
|rowclass(n)=
|class(n)=
|data(n)=
|rowclass(n)=
|label(n)=
|class(n)=
|data(n)=
Number ranges[edit source]
To allow flexibility when the layout of an infobox is changed, it may be helpful when developing an infobox to use non-contiguous numbers for header and label/data rows. Parameters for new rows can then be inserted in future without having to renumber existing parameters. For example:
| header3 = Section 1
| label5 = Label A
| data5 = Data A
| label7 = Label C
| data7 = Data C
| header10 = Section 2
| label12 = Label D
| data12 = Data D
There is no upper limit on numbers but there must be at most 50 between each used number.
Making data fields optional[edit source]
A row with a label but no data is not displayed. This allows for the easy creation of optional infobox content rows. To make a row optional use a parameter that defaults to an empty string, like so:
| label5 = Population
| data5 = {{{population|}}}
This way if an article doesn't define the population parameter in its infobox the row won't be displayed.
For more complex fields with pre-formatted contents that would still be present even if the parameter wasn't set, you can wrap it all in an "#if" statement to make the whole thing vanish when the parameter is not used. For instance, the "#if" statement in the following example reads "#if:the parameter mass has been supplied |then display it, followed by 'kg'":
| label6 = Mass
| data6 = {{ #if: {{{mass|}}} | {{{mass}}} kg }}
For more on #if, see here.
[edit source]
- footer
- Text to put in the bottom cell. The bottom cell is intended for footnotes, navigation links, see-also, and other such information.
HTML classes[edit source]
- bodyclass
- This parameter is inserted into the
class
attribute for the infobox as a whole. - titleclass
- This parameter is inserted into the
class
attribute for the infobox's title cell. - imagerowclass(n)
- These parameters are inserted into the
class
attribute for the complete table row their respective image is on. - imageclass
- This parameter is inserted into the
class
attribute for the image. - rowclass(n)
- This parameter is inserted into the
class
attribute for the specified row including the label and data cells. - class(n)
- This parameter is inserted into the
class
attribute for the data cell of the specified row. If there's no data cell it has no effect. - footerclass
- This parameter is inserted into the
class
attribute for the infobox's footer cell.
TemplateData[edit source]
TemplateData for Infobox
This template is intended as a meta template, a template used for constructing other templates. In general, it is not meant for use directly in an article but can be used on a one-off basis if required.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Title | title | Title displayed in the uppermost cell of the infobox | String | suggested |
Image | image | Image illustrating the topic. Use full image syntax.
| Content | suggested |
Caption | caption | caption for the image | Content | suggested |