Navigation menu

Template:Infobox/doc: Difference between revisions

From The Kodiak Republic Wiki

no edit summary
m (7 revisions imported from templatewikiarchive:Template:Infobox/doc)
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1:
{{distinguish|Template:Userbox}}
{{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
Line 15 ⟶ 17:
}}
 
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. [[w:Help:Infobox]] contains an introduction about the recommended content and design of infoboxes; [[Wikipedia:Manual of Style/Infoboxes]] contains additional style guidelines. See [[WP:List of infoboxes]] and [[:Category:Infobox templates]] for lists of prepared topic-specific infoboxes.
 
== Usage ==
{{tlf|Infobox}} is a meta-template: used to organise an actual <nowiki>{{Infobox sometopic}}</nowiki> template (like {{tl|Infobox building}}).
Usage is similar to {{tl|navbox}}, but with an additional distinction. Each row on the table can contain either a header, or a label/data pair, or just a data cell. These are mutually exclusive states so if you define a row with both a header and a label/data pair, the label/data pair is ignored.
 
For <code><nowiki>[[Template:Infobox sometopic]]</nowiki></code>, template code then looks like this, simplified:
To insert an image somewhere other than at the top of the infobox, or to insert freeform data, use a row with only a data field.
<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, pointing to the named page, prefixed by <code>Template:</code> if no namespace is specified. You may use the value <nowiki>{{subst:PAGENAME}}</nowiki>; however, this is rarely what you want, because it will send users clicking these links in an infobox in an article to the template code rather than the data in the infobox that they probably want to change.
; 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 it on top of the table. You can use them both of them together if you like, or just one or the other, or even neither (though this is not recommended):
 
; 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 101 ⟶ 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 119 ⟶ 142:
</pre>{{clear}}
 
For more on #if, see [[mw:Help:Extensionmeta:ParserFunctions##if:|here]].
 
==== Hiding headers when all its data fields are hiddenempty ====
You can also make headers optionalautomatically inhide awhen similartheir way.section Consideris thisempty example:(has no data-row showing).
 
Consider this situation:
{{Infobox
| title = Example: ofheader anwith undesirable& headerwithout data
| headerstyle = background:lightgrey
| header1 = Undesirable header
 
| label2 = Item 1 | data2 =
| header1 = Header1 with empty section
| label3 = Item 2 | data3 =
| label4label2 = Item 3 label2 text | data4data2 =
| label3 = label3 text | data3 =
| header5 = Static header
| label6label4 = Staticlabel4 itemtext | data6data4 = Static value
 
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
<pre style="overflow:auto">
{{Infobox
| title = Example: ofheader anwith undesirable& headerwithout data
| headerstyle = background:lightgrey
| header1 = Undesirable header
 
| label2 = Item 1 | data2 =
| header1 = Header1 with empty section
| label3 = Item 2 | data3 =
| label4label2 = Item 3 label2 text | data4data2 =
| label3 = label3 text | data3 =
| header5 = Static header
| label6label4 = Staticlabel4 itemtext | data6data4 = Static value
 
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</pre>{{clear}}
 
If you want hide the first header towhen appear only if one or more of theno {{para|data''N''}} fields that fall under itvalues are filledpresent, one could use the following pattern as an example of how to do it'''{{para|autoheaders|y}}''':
 
{{Infobox
| title = Example: ofheader anwith optional& headerwithout data
| autoheaders = y
| header1 = {{ #if: {{{item1|}}}{{{item2|}}}{{{item3|}}} | Optional header }}
| headerstyle = background:lightgrey
| label2 = Item 1 | data2 = {{{item1|}}}
 
| label3 = Item 2 | data3 = {{{item2|}}}
| header1 = Header1 with empty section
| label4 = Item 3 | data4 = {{{item3|}}}
| label2 = label2 text | data2 =
| header5 = Static header
| label6label3 = Staticlabel3 itemtext | data6data3 = Static value
| label4 = label4 text | data4 =
 
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
 
<pre style="overflow:auto">
<syntaxhighlight lang="moin" style="overflow:auto">
{{Infobox
| title = Example: ofheader anwith optional& headerwithout data
| autoheaders = y
| header1 = {{ #if: {{{item1|}}}{{{item2|}}}{{{item3|}}} | Optional header }}
| headerstyle = background:lightgrey
| label2 = Item 1 | data2 = {{{item1|}}}
 
| label3 = Item 2 | data3 = {{{item2|}}}
| header1 = Header1 with empty section
| label4 = Item 3 | data4 = {{{item3|}}}
| label2 = label2 text | data2 =
| header5 = Static header
| label6label3 = Staticlabel3 itemtext | data6data3 = Static value
| label4 = label4 text | data4 =
 
| header5 = Header5 with data below
| label6 = label6 text | data6 = Some value
}}
</presyntaxhighlight>{{clear}}
 
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 staticvisible content. The trick to this is that the "#if" returns false only if there is nothing whatsoever in the conditional section, so only if all three of item1, item2 and item3 are undefined will the if statement fail.
 
Note: if the data has empty css elements, like {{para|data|2=&lt;span style="background:yellow;">&lt;/span>}}, this will be treated as non-empty (having data).
Note that such trick may be sometimes very complex to test if there are many data items whose value depends on complex tests (or when a data row is generated by a recursive invocation of this template as a [[#Subboxes|subbox]]). Ideally, the Lua module supporting this template should now support a new way to make each header row autohideable by detecting if there is at least one non-empty data row after that header row (a parameter like "autohide header1 = yes", for example, would remove the need to perform the "#if" test so that we can just to define "header1 = Optional header"),
 
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 184 ⟶ 256:
 
=== 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 191 ⟶ 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 212 ⟶ 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 beigbeing used for microformats.
 
To flag an infobox as containing [[w:hCard|hCard]] information, for example, add the following parameter:
 
<pre style="overflow:auto">
Line 231 ⟶ 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 [[wWikipedia:WikiProject Microformats]] for more information on adding microformat information to Wikipedia, and [[microformat]] for more information on microformats in general.
 
== Examples ==
Line 241 ⟶ 318:
 
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
Line 276 ⟶ 353:
|below = Below text
}}
<presyntaxhighlight lang="Sass" style="overflow:auto" highlight="15">
{{Infobox
|name = {{subst:PAGENAME}}
Line 282 ⟶ 359:
 
|titlestyle =
|abovestyle = background:#cfc;
|subheaderstyle =
|title = Test Infobox
Line 317 ⟶ 394:
|below = Below text
}}
</presyntaxhighlight>{{clear}}
 
For this example, the '''{{para|bodystyle'''}} and '''{{para|labelstyle'''}} parameters are used to adjust the infobox width and define a default width for the column of labels:
 
{{Infobox
Line 351 ⟶ 428:
|below = Below text
}}
<presyntaxhighlight lang="sass" highlight="3,9" style="overflow: auto">
{{Infobox
|name = {{subst:PAGENAME}}
Line 382 ⟶ 459:
|below = Below text
}}
</presyntaxhighlight>{{clear}}
 
== Embedding ==
<!--Linked from [[Template:Subinfobox bodystyle/doc]]-->
One infobox template can be embedded into another using the {{para|child}} parameter or the {{para|embed}} 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 491 ⟶ 568:
</pre>{{clear}}
 
Note that omitting the {{para|title}} parameter, and not including any text preceding the embedded infobox, may result in spurious blank table rows, creating gaps in the visual presentation. The garbage output can be suppressed using {{para|rowstyleN|display: none}}, replacing N with the data/header number.
 
[[Wikipedia:WikiProject Infoboxes/embed]] includes some links to Wikipedia articles which include infoboxes embedded within other infoboxes.
 
== Subboxes ==
Line 515 ⟶ 594:
| header6 = Main 6
}}
<sourcesyntaxhighlight lang="sass" style="overflow:auto">
{{Infobox
| headerstyle = background-color:#eee;
Line 535 ⟶ 614:
| header6 = Main 6
}}
</sourcesyntaxhighlight>{{clear}}
 
Similar embedding techniques may be used within content parameters of some other templates generating tables (such as [[:Template:Sidebar|Sidebar]]) :
Line 557 ⟶ 636:
| heading5 = Heading 5
}}
<sourcesyntaxhighlight lang="sass" style="overflow:auto">
{{Sidebar
| navbar = off
Line 576 ⟶ 655:
| heading5 = Heading 5
}}
</sourcesyntaxhighlight>{{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 589 ⟶ 671:
| subbox = {{{subbox|}}}
| italic title = {{{italic title|no}}}
| templatestyles =
| child templatestyles =
| grandchild templatestyles =
| bodystyle =
 
Line 674 ⟶ 759:
</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 [[mwWP:Lua/OverviewLUA|Lua]] module on which this template is based
* [[Module:Check for unknown parameters]]
* {{tl|Infobox3cols}}
* {{tl|Navbox}} and {{tl|Sidebar}}
* [[Wikipedia:List of infoboxes|List of infoboxes]]
* [[:Module:InfoboxImage]]
 
* Maintenance categories:
<includeonly>{{Sandbox other||
** [[:Category:Articles which use infobox templates with no data rows]]
<!-- Categories below this line, please; interwikis at Wikidata -->
** [[:Category:Pages which use embedded infobox templates with the title parameter]]
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
[[Category:Infobox templates| ]]
[[Category:MetatemplatesWikipedia metatemplates|Infobox]]
[[Category:Templates generating microformats]]
[[Category:Templates that add a tracking category]]
[[Category:Templates based on the Infobox Lua module]]
 
}}</includeonly>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.