Changes

Jump to navigation Jump to search

Template:Infobox/doc

203 bytes added, 20:30, 16 March 2008
m
→‎Making fields optional: a little rewording to hopefully make this clearer
===Making fields optional===
A row with a label but no data is not displayed. This allows for the easy creation of optional infobox contentscontent rows. To make a field row optional, use a parameter that defaults to an empty string, like so:
<pre>
|label5 = Population
| data5 = {{{population|}}}
</pre>
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-formated contents that would still be present even if a the parameter was unsetwasn't set, you can wrap it all in a simple an "if" statement to make the whole thing vanish when the parameter is not used. Example:
<pre>
| data5 label6 = Mass| data6 = {{#if: {{{mass|}}} | {{{mass}}} kg}}
</pre>
</pre>
header1 will be shown if any of item_one, item_two, or item_three is defined, and won't be shown if . If none of those the three parameters are definedthe 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.
Anonymous user

Navigation menu