Open main menu

Changes

Template:Infobox/doc

745 bytes added, 05:35, 28 January 2008
→‎Making fields optional: How to make headers optional
|data5= {{#if: {{{mass|}}} | {{{mass}}} kg}}
</pre>
 
You can 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:
 
<pre>
{{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>
 
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