Open main menu

Changes

Template:Infobox/doc

84 bytes added, 15:08, 2 October 2013
no edit summary
=== Control parameters ===
 
; name : If this parameter is present, "view/discuss/edit" links will be added to the bottom of the infobox, pointing to the named page. 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 : Optional parameter: See the [[#Embedding|embeddingEmbedding]] section for details. If this is set to a non-empty value, this child infobox should be titled but have no name parameter.; subbox : Optional parameter: See the [[#EmbeddingSubboxes|embeddingSubboxes]] section for details. If this is set to a non-empty value, this subbox should be titled but have no name parameter.
=== Content parameters ===
* {{para|rowclass''(n)''}} {{para|label''(n)''}} {{para|class''(n)''}} {{para|data''(n)''}}
See the rendering of header4, label4, and data4 in the examples [[#Examples|Examples]] section below. ===== Making fields optional =====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: <pre style="overflow:auto"> | label5 = Population | data5 = {{{population|}}}</pre>{{clear}} 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'": <pre style="overflow:auto"> | label6 = Mass | data6 = {{#if:{{{mass|}}}|{{{mass}}} kg}}</pre>{{clear}} For more on #if, see [[meta:ParserFunctions##if:|here]]. You can also make headers optional in a similar way. If you want a header to appear only if one or more of the data fields that fall under it are filled, one could use the following pattern as an example of how to do it: {{Infobox |name = Infobox/doc |title = Example of an optional header |header1 = {{#if:{{{item_one|}}}{{{item_two|}}}{{{item_three|}}}|Optional header}} | label2 = Item one | data2 = {{{item_one|}}} | label3 = Item two | data3 = {{{item_two|}}} | label4 = Item three | data4 = {{{item_three|}}}}}<pre style="overflow:auto">{{Infobox |name = {{subst:PAGENAME}} |title = Example of an optional header |header1 = {{#if:{{{item_one|}}}{{{item_two|}}}{{{item_three|}}}|Optional header}} | label2 = Item one | data2 = {{{item_one|}}} | label3 = Item two | data3 = {{{item_two|}}} | label4 = Item three | data4 = {{{item_three|}}}}}</pre>{{clear}} header1 will be shown if any of item_one, item_two, or item_three is defined. If none of the three parameters are defined the header won't be shown. 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 item_one, item_two and item_three are undefined will the if statement fail.
==== Footer ====
* Turn on italic titles by passing {{para|italic title|<nowiki>{{{italic title|}}}</nowiki>}} from the infobox.
* 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|<nowiki>{{{italic title|no}}}</nowiki>}}
* Do not make any titles italic by not passing the parameter at all.
See [[Wikipedia:WikiProject Microformats]] for more information on adding microformat information to Wikipedia, and [[microformat]] for more information on microformats in general.
 
=== Making fields optional ===
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:
 
<pre style="overflow:auto">
| label5 = Population
| data5 = {{{population|}}}
</pre>{{clear}}
 
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'":
 
<pre style="overflow:auto">
| label6 = Mass
| data6 = {{#if:{{{mass|}}}|{{{mass}}} kg}}
</pre>{{clear}}
 
For more on #if, see [[meta:ParserFunctions##if:|here]].
 
You can also make headers optional in a similar way. If you want a header to appear only if one or more of the data fields that fall under it are filled, one could use the following pattern as an example of how to do it:
 
{{Infobox
|name = Infobox/doc
|title = Example of an optional header
|header1 = {{#if:{{{item_one|}}}{{{item_two|}}}{{{item_three|}}}|Optional header}}
| label2 = Item one
| data2 = {{{item_one|}}}
| label3 = Item two
| data3 = {{{item_two|}}}
| label4 = Item three
| data4 = {{{item_three|}}}
}}
<pre style="overflow:auto">
{{Infobox
|name = {{subst:PAGENAME}}
|title = Example of an optional header
|header1 = {{#if:{{{item_one|}}}{{{item_two|}}}{{{item_three|}}}|Optional header}}
| label2 = Item one
| data2 = {{{item_one|}}}
| label3 = Item two
| data3 = {{{item_two|}}}
| label4 = Item three
| data4 = {{{item_three|}}}
}}
</pre>{{clear}}
 
header1 will be shown if any of item_one, item_two, or item_three is defined. If none of the three parameters are defined the header won't be shown.
 
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 item_one, item_two and item_three are undefined will the if statement fail.
=== Examples ===
Anonymous user