Template:Infobox/doc: Difference between revisions
Template page
More actions
m fix categorization |
syntaxhighlight lang="wikitext" |
||
| Line 21: | Line 21: | ||
For <code><nowiki>[[Template:Infobox sometopic]]</nowiki></code>, template code then looks like this, simplified: | For <code><nowiki>[[Template:Infobox sometopic]]</nowiki></code>, template code then looks like this, simplified: | ||
< | <syntaxhighlight lang="wikitext"> | ||
{{Infobox | {{Infobox | ||
| name = {{{name|{{PAGENAME}}}}} | | name = {{{name|{{PAGENAME}}}}} | ||
| Line 36: | Line 36: | ||
... <!-- etc. --> | ... <!-- etc. --> | ||
}} | }} | ||
</ | </syntaxhighlight> | ||
== Optional control parameters == | == Optional control parameters == | ||
| Line 62: | Line 62: | ||
| header = (the rest of the infobox goes here) | | header = (the rest of the infobox goes here) | ||
}} | }} | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| name = {{subst:PAGENAME}} | | name = {{subst:PAGENAME}} | ||
| Line 69: | Line 69: | ||
| header = (the rest of the infobox goes here) | | header = (the rest of the infobox goes here) | ||
}} | }} | ||
</ | </syntaxhighlight>{{clear}} | ||
{{Infobox | {{Infobox | ||
| Line 78: | Line 78: | ||
| header = (the rest of the infobox goes here) | | header = (the rest of the infobox goes here) | ||
}} | }} | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| name = {{subst:PAGENAME}} | | name = {{subst:PAGENAME}} | ||
| Line 86: | Line 86: | ||
| header = (the rest of the infobox goes here) | | header = (the rest of the infobox goes here) | ||
}} | }} | ||
</ | </syntaxhighlight>{{clear}} | ||
=== Illustration images === | === Illustration images === | ||
| Line 108: | Line 108: | ||
To allow flexibility when the layout of an infobox is changed, it may be helpful when developing an infobox to use non-contiguous numbers for header and label/data rows. Parameters for new rows can then be inserted in future without having to renumber existing parameters. For example: | To allow flexibility when the layout of an infobox is changed, it may be helpful when developing an infobox to use non-contiguous numbers for header and label/data rows. Parameters for new rows can then be inserted in future without having to renumber existing parameters. For example: | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
| header3 = Section 1 | | header3 = Section 1 | ||
| label5 = Label A | | label5 = Label A | ||
| Line 117: | Line 117: | ||
| label12 = Label D | | label12 = Label D | ||
| data12 = Data D | | data12 = Data D | ||
</ | </syntaxhighlight>{{clear}} | ||
It is also possible to automatically renumber parameter names by using [[User:Frietjes/infoboxgap.js]] or [[Module:IncrementParams]]. | It is also possible to automatically renumber parameter names by using [[User:Frietjes/infoboxgap.js]] or [[Module:IncrementParams]]. | ||
| Line 124: | Line 124: | ||
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: | 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: | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
| label5 = Population | | label5 = Population | ||
| data5 = {{{population|}}} | | data5 = {{{population|}}} | ||
</ | </syntaxhighlight>{{clear}} | ||
This way if an article doesn't define the population parameter in its infobox the row won't be displayed. | This way if an article doesn't define the population parameter in its infobox the row won't be displayed. | ||
| Line 133: | Line 133: | ||
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'": | 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'": | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
| label6 = Mass | | label6 = Mass | ||
| data6 = {{ #if: {{{mass|}}} | {{{mass}}} kg }} | | data6 = {{ #if: {{{mass|}}} | {{{mass}}} kg }} | ||
</ | </syntaxhighlight>{{clear}} | ||
For more on #if, see [[meta:ParserFunctions##if:|here]]. | For more on #if, see [[meta:ParserFunctions##if:|here]]. | ||
| Line 156: | Line 156: | ||
| label6 = label6 text | data6 = Some value | | label6 = label6 text | data6 = Some value | ||
}} | }} | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| title = Example: header with & without data | | title = Example: header with & without data | ||
| Line 169: | Line 169: | ||
| label6 = label6 text | data6 = Some value | | label6 = label6 text | data6 = Some value | ||
}} | }} | ||
</ | </syntaxhighlight>{{clear}} | ||
If you want hide the header when no {{para|data''N''}} values are present, use '''{{para|autoheaders|y}}''': | If you want hide the header when no {{para|data''N''}} values are present, use '''{{para|autoheaders|y}}''': | ||
| Line 187: | Line 187: | ||
}} | }} | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| title = Example: header with & without data | | title = Example: header with & without data | ||
| Line 223: | Line 223: | ||
}} | }} | ||
<syntaxhighlight lang=" | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| title = Example: header with & without data | | title = Example: header with & without data | ||
| Line 290: | Line 290: | ||
To flag an infobox as containing [[hCard]] information, for example, add the following parameter: | To flag an infobox as containing [[hCard]] information, for example, add the following parameter: | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
| bodyclass = vcard | | bodyclass = vcard | ||
</ | </syntaxhighlight>{{clear}} | ||
And for each row containing a data cell that's part of the vcard, add a corresponding class parameter: | And for each row containing a data cell that's part of the vcard, add a corresponding class parameter: | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
| class1 = fn | | class1 = fn | ||
| class2 = org | | class2 = org | ||
| class3 = tel | | class3 = tel | ||
</ | </syntaxhighlight>{{clear}} | ||
...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. | ...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. | ||
| Line 476: | Line 476: | ||
| below = Below text | | below = Below text | ||
}} | }} | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| title = Top level title | | title = Top level title | ||
| Line 492: | Line 492: | ||
| below = Below text | | below = Below text | ||
}} | }} | ||
</ | </syntaxhighlight>{{clear}} | ||
Note, in the examples above, the child infobox is placed in a <code>data</code> field, not a <code>header</code> field. Notice that the section subheadings are not in bold font if bolding is not explicitly specified. To obtain bold section headings, place the child infobox in a '''header''' field (but not in a '''label''' field because it would not be displayed!), either using | Note, in the examples above, the child infobox is placed in a <code>data</code> field, not a <code>header</code> field. Notice that the section subheadings are not in bold font if bolding is not explicitly specified. To obtain bold section headings, place the child infobox in a '''header''' field (but not in a '''label''' field because it would not be displayed!), either using | ||
| Line 511: | Line 511: | ||
| below = Below text | | below = Below text | ||
}} | }} | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| title = Top level title | | title = Top level title | ||
| Line 527: | Line 527: | ||
| below = Below text | | below = Below text | ||
}} | }} | ||
</ | </syntaxhighlight>{{clear}} | ||
or, | or, | ||
| Line 546: | Line 546: | ||
| below = Below text | | below = Below text | ||
}} | }} | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| title = Top level title | | title = Top level title | ||
| Line 562: | Line 562: | ||
| below = Below text | | below = Below text | ||
}} | }} | ||
</ | </syntaxhighlight>{{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. | 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. | ||
| Line 661: | Line 661: | ||
(Note: there is no limit to the number of possible rows; only 20 are given below since infoboxes larger than that will be relatively rare. Just extend the numbering as needed. The microformat "class" parameters are also omitted as they are not commonly used.) | (Note: there is no limit to the number of possible rows; only 20 are given below since infoboxes larger than that will be relatively rare. Just extend the numbering as needed. The microformat "class" parameters are also omitted as they are not commonly used.) | ||
< | <syntaxhighlight lang="wikitext" style="overflow:auto"> | ||
{{Infobox | {{Infobox | ||
| name = {{subst:PAGENAME}} | | name = {{subst:PAGENAME}} | ||
| Line 753: | Line 753: | ||
| below = | | below = | ||
}} | }} | ||
</ | </syntaxhighlight>{{clear}} | ||
{{Help:Infobox/user style}} | {{Help:Infobox/user style}} | ||