Template:Infobox/doc: Difference between revisions
From The Kodiak Republic Wiki
no edit summary
m (10 revisions imported from dev:Template:Infobox/doc) |
No edit summary |
||
Line 1:
{{Documentation subpage}}
<!-- Please place categories where indicated at the bottom of this page and interwikis at Wikidata (see [[Wikipedia:Wikidata]]) -->
{{distinguish|Template:Userbox}}
{{#ifeq:{{SUBPAGENAME}}|sandbox||{{High-use}}}}
{{Lua|Module:Infobox}}
{{Parameter names example
|name={{PAGENAME}} <!--|child |subbox |decat--> |title |above |subheader |subheader1 |subheader2={{{subheader2}}}<br/>......
|image|caption |image1|caption1 |image2|caption2={{{caption2}}}<br/>......
|header1=<div style="border-top:1px dashed #ccc;">{{{header1}}}<br/>{{nobold|( ''or'' )}}</div>
|label2={{{label1}}} |data2={{{data1}}}
|data3=( ''or'' ) |data4=<div style="padding-bottom:0.25em;border-bottom:1px dashed #ccc;">{{{data1}}}</div>
|header5={{{header2}}}<br/><div style="padding:0.75em 0 0.5em;">{{nobold|( ''or'' )}}</div>
|label6={{{label2}}} |data6={{{data2}}}
|data7=( ''or'' ) |data8=<div style="padding-bottom:0.25em;border-bottom:1px dashed #ccc;">{{{data2}}}</div>
|data9=<div style="padding:0.75em 0 0.5em;">( ''etc'' )</div>
|below
}}
This template is intended as a meta template: a template used for constructing other templates. '''Note''': In general, it is not meant for use directly in an article, but can be used on a one-off basis if required. [[
== Usage ==
{{tlf|Infobox}} is a meta-template: used to organise an actual <nowiki>{{Infobox sometopic}}</nowiki> template (like {{tl|Infobox building}}).
For <code><nowiki>[[Template:Infobox sometopic]]</nowiki></code>, template code then looks like this, simplified:
<pre>
{{Infobox
| name = {{{name|{{PAGENAME}}}}}
| image = {{{image|}}}
| caption1 = {{{caption|}}}
| label1 = Former names
| data1 = {{{former_names|}}}
| header2 = General information
| label3 = Status
| data3 = {{{status|}}}
... <!-- etc. -->
}}
</pre>
== Optional control parameters ==
; name : If this parameter is present, "view/talk/edit" links will be added to the bottom of the infobox
; child : See the [[#Embedding|Embedding]] section for details. If this is set to "yes", this child infobox should be titled but have no name parameter. This parameter is empty by default, set it to "yes" to activate it.
; subbox : See the [[#Subboxes|Subboxes]] section for details. If this is set to "yes", this subbox should be titled but have no name parameter. This parameter is empty by default, set to "yes" to activate it. It has no effect if the '''child''' parameter is also set to "yes".
; decat : 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.
; autoheaders: If this is set to any non-blank value, headers which are not followed by data fields are suppressed. See the "[[#Hiding headers when all its data fields are empty|hiding headers when all its data fields are empty]]" section for more details.
== Content parameters ==
=== Title ===
There are two different ways to put a title on an infobox. One contains the title inside the infobox's border in the uppermost cell of the table, the other puts it as a caption
; title : Text to put in the caption over the top of the table (or as section header before the whole content of this table, if this is a child infobox). For [[Wikipedia:Manual of Style/Accessibility#Tables|accessibility reasons]], this is the most recommended alternative.
; above : Text to put within the uppermost cell of the table.
; subheader(n) : additional title fields which fit below {{{title}}} and {{{above}}}, but before images.
Line 58 ⟶ 91:
=== Illustration images ===
; image(n) : images to display at the top of the template. Use full image syntax, for example <nowiki>[[File:example.png|200px|alt=Example alt text]]</nowiki>. Image is centered by default. See [[WP:ALT]] for more on alt text.
; caption(n) : Text to put underneath the images.
Line 66 ⟶ 99:
; 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 {{para|header''(n)''
* {{para|class''(n)''
* {{para|rowclass''(n)'
* {{para|rowclass''(n)''
See the rendering of header4, label4, and data4 in the [[#Examples|Examples]] section below.
Line 87 ⟶ 120:
| data12 = Data D
</pre>{{clear}}
It is also possible to automatically renumber parameter names by using [[User:Frietjes/infoboxgap.js]] or [[Module:IncrementParams]].
There is no upper limit on numbers but there must be at most 50 between each used number.
==== Making data fields optional ====
Line 105 ⟶ 142:
</pre>{{clear}}
For more on #if, see [[
==== Hiding headers when all its data fields are
You can also make headers
Consider this situation:
{{Infobox
| title = Example:
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
|
| label3 = label3 text | data3 =
|
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<pre style="overflow:auto">
{{Infobox
| title = Example:
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
|
| label3 = label3 text | data3 =
|
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</pre>{{clear}}
If you want hide the
{{Infobox
| title = Example:
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
|
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<syntaxhighlight lang="moin" style="overflow:auto">
{{Infobox
| title = Example:
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
|
| label4 = label4 text | data4 =
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</
So, header1 will be shown if any of item1, item2, or item3 is defined. If none of the three parameters are defined the header won't be shown and no empty row appears before the next
Note: if the data has empty css elements, like {{para|data|2=<span style="background:yellow;"></span>}}, this will be treated as non-empty (having data).
If {{para|autoheaders|y}} but there are items that you ''do not'' want to trigger a header, place {{para|headerX|_BLANK_}}. This will serve as an empty header and separate it from the subsequent items.
{{Infobox
| title = Example: blank header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = _BLANK_
| label6 = label6 text | data6 = Some value, but does not trigger header1 or show header5
}}
<syntaxhighlight lang="moin" style="overflow:auto">
{{Infobox
| title = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
| header1 = Header1 with empty section
| label2 = label2 text | data2 =
| label3 = label3 text | data3 =
| label4 = label4 text | data4 =
| header5 = _BLANK_
| label6 = label6 text | data6 = Some value, but does not trigger header1 or show header5
}}
</syntaxhighlight>{{clear}}
=== Footer ===
Line 163 ⟶ 249:
=== Italic titles ===
Titles of articles with infoboxes may be made italic, in line with [[WP:ITALICTITLE]], by passing the <code>italic title</code> parameter.
* Turn on italic titles by passing {{para|italic title
* Turn off by default (notably because only Latin script may be safely rendered in this style and italic may be needed to distinguish foreign language from local English language only in that script, but would be difficult to read for other scripts) but allow some instances to be made italic by passing {{para|italic title
* Do not make any titles italic by not passing the parameter at all.
=== CSS styling ===
{{div col}}
; bodystyle : Applies to the infobox table as a whole
; titlestyle : Applies only to the title caption. Adding a background color is usually inadvisable since the text is rendered "outside" the infobox.
Line 177 ⟶ 264:
; rowstyle(n) : This parameter is inserted into the <code>style</code> attribute for the specified row.
; headerstyle : Applies to all header cells
; subheaderstyle : Applies to all subheader cells
; labelstyle : Applies to all label cells
; datastyle : Applies to all data cells
; belowstyle : Applies only to the below cell
{{div col end}}
=== HTML classes and microformats ===
{{div col}}
; bodyclass : This parameter is inserted into the <code>class</code> attribute for the infobox as a whole.
; titleclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''title''' caption.
Line 198 ⟶ 288:
-->
; belowclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''below''' cell.
{{div col end}}
This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others
To flag an infobox as containing [[
<pre style="overflow:auto">
Line 217 ⟶ 308:
...and so forth. "above" and "title" can also be given classes, since these are usually used to display the name of the subject of the infobox.
See [[
== Examples ==
Line 227 ⟶ 318:
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
Line 262 ⟶ 353:
|below = Below text
}}
<
{{Infobox
|name = {{subst:PAGENAME}}
Line 268 ⟶ 359:
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
Line 303 ⟶ 394:
|below = Below text
}}
</
For this example, the
{{Infobox
Line 337 ⟶ 428:
|below = Below text
}}
<
{{Infobox
|name = {{subst:PAGENAME}}
Line 368 ⟶ 459:
|below = Below text
}}
</
== Embedding ==
<!--Linked from [[Template:Subinfobox bodystyle/doc]]-->
One infobox template can be embedded into another using the {{para|child}} parameter. This feature can be used to create a modular infobox, or to create better-defined logical sections. Long ago, it was necessary to use embedding in order to create infoboxes with more than 99 rows; but nowadays there's no limit to the number of rows that can be defined in a single instance of <code><nowiki>{{infobox}}</nowiki></code>.
{{Infobox
Line 476 ⟶ 568:
</pre>{{clear}}
Note that omitting the {{para|title
[[Wikipedia:WikiProject Infoboxes/embed]] includes some links to Wikipedia articles which include infoboxes embedded within other infoboxes.
== Subboxes ==
An alternative method for embedding is to use {{para|subbox
{{Infobox
Line 500 ⟶ 594:
| header6 = Main 6
}}
<
{{Infobox
| headerstyle = background-color:#eee;
Line 520 ⟶ 614:
| header6 = Main 6
}}
</
Similar embedding techniques may be used within content parameters of some other templates generating tables (such as [[:Template:Sidebar|Sidebar]]) :
{{Sidebar
| navbar = off
| headingstyle = background-color:#eee;
| heading1 = Heading 1
| heading2 = Heading 2
| content3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| content4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| heading5 = Heading 5
}}
<syntaxhighlight lang="sass" style="overflow:auto">
{{Sidebar
| navbar = off
| headingstyle = background-color:#eee;
| heading1 = Heading 1
| heading2 = Heading 2
| content3 = {{Infobox | subbox = yes
| headerstyle = background-color:#ccc;
| labelstyle = background-color:#ddd;
| header1 = Sub 3-1
| header2 = Sub 3-2
| label3 = Label 3-3 | data3 = Data 3-3
}}
| content4 = {{Infobox | subbox = yes
| labelstyle = background-color:#ccc;
| label1 = Label 4-1 | data1 = Data 4-1
}}
| heading5 = Heading 5
}}
</syntaxhighlight>{{clear}}
Note that the default padding of the parent data cell containing each subbox is still visible, so the subboxes are slightly narrower than the parent box and there's a higher vertical spacing between standard cells of the parent box than between cells of distinct subboxes.
== Controlling line-breaking in embedded bulletless lists ==
Template {{tlx|nbsp}} may be used with {{tlx|wbr}} and {{tlx|nowrap}} to control line-breaking in bulletless lists embedded in infoboxes (e.g. cast list in {{tlx|Infobox film}}), to prevent wrapped long entries from being confused with multiple entries. See [[Template:Wbr/doc#Controlling line-breaking in infoboxes]] for details.
== Full blank syntax ==
Line 534 ⟶ 671:
| subbox = {{{subbox|}}}
| italic title = {{{italic title|no}}}
| templatestyles =
| child templatestyles =
| grandchild templatestyles =
| bodystyle =
Line 618 ⟶ 758:
}}
</pre>{{clear}}
{{Help:Infobox/user style}}
== Porting to other MediaWikis ==
The infobox template requires the [[:mw:Extension:Scribunto|Scribunto]] extension. [[Wikipedia:WikiProject Transwiki|WikiProject Transwiki]] has a version of this template that has been modified to work on other MediaWikis.
== TemplateData ==
{{TemplateData header}}
<templatedata>
{
"description": "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.",
"format": "{{_\n| ________________ = _\n}}\n",
"params": {
"title": {
"label": "Title",
"description": "Title displayed above the infobox",
"type": "string",
"suggested": true
},
"image": {
"label": "Image",
"description": "Image illustrating the topic. Use full image syntax.",
"type": "content",
"suggested": true,
"example": "[[File:example.png|200px|alt=Example alt text]]"
},
"caption": {
"label": "Caption",
"description": "caption for the image",
"type": "content",
"suggested": true
}
},
"paramOrder": [
"title",
"image",
"caption"
]
}
</templatedata>
==Tracking categories==
* {{Category link with count|Articles with missing Wikidata information}}
* {{Category link with count|Articles using infobox templates with no data rows}}
* {{Category link with count|Pages using embedded infobox templates with the title parameter}}
==See also==
* [[Module:Infobox]], the [[
* [[Module:Check for unknown parameters]]
* {{tl|Infobox3cols}}
* {{tl|Navbox}} and {{tl|Sidebar}}
* [[Wikipedia:List of infoboxes|List of infoboxes]]
* [[:Module:InfoboxImage]]
<includeonly>{{Sandbox other||
<!-- Categories below this line, please; interwikis at Wikidata -->
[[Category:Infobox templates| ]]
[[Category:Wikipedia metatemplates|Infobox]]
[[Category:Templates generating microformats]]
[[Category:Templates that add a tracking category]]
[[Category:Templates based on the Infobox Lua module]]
}}</includeonly>
|