Template:Infobox/doc View history

No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
{{doc subpage}}
{{doc subpage}}
<!-- ADD DOCUMENTATION BELOW THIS LINE -->
<!-- ADD DOCUMENTATION BELOW THIS LINE -->
TThis template is intended as a meta-template, that is, a template that's used when constructing other templates. It's not meant for use directly in an article. See [[Help:Infobox]] for information on how to craft infoboxes in general.
Description:
 
*This template produces an [[Help:Infobox|infobox]]-style template.
Usage is similar to {{tl|navbox}}, but with an additional distinction. Each row on the table can either be a "header", or it can have a label/data pair, or it can just be a data cell. These are mutually exclusive states so if you define a row to be both a header and a label/data pair, the label/data pair is overridden.
*You may want to copy and modify this to create a specific infobox (e.g. character infobox).
 
*This template requires [[Help:Parser functions|parser functions]] to be enabled (Wikia default: on).
Note that if you want to insert an image elsewhere other than the top of the infobox, or insert other "freeform" data, using a row with just a "data" field allows for that sort of thing.
 
===Parameters===
 
Mandatory:
;name : The template page name that the "view/discuss/edit" links should point to. You can use <nowiki>{{subst:PAGENAME}}</nowiki>.
;title : A title to put in the titlebar at the top.
If no name or title are given, the pagename is used.
Optional content:
 
; image : An image to display at the top of the template. Use full image syntax, for example <nowiki>[[Image:example.png|200px]]</nowiki>. Image is centered by default.
;caption : Text to put underneath the image.
;header(n) : Text to use as a header in row n.
;label(n): Text to use as a label in row n.
;data(n): Text to display as data in row n.
;below: Text to put in the bottom cell. The bottom cell is intended for footnotes, see-also, and other such information.
 
 
Optional CSS styling:
 
;bodystyle : Applies to the infobox table as a whole
;titlestyle : Applies only to the title cell
;imagestyle : Applies to the cell the image is in (including the caption)
;captionstyle : Applies to the text of the caption
;headerstyle : Applies to all header cells
;labelstyle : Applies to all label cells
;datastyle : Applies to all data cells
;belowstyle : Applies only to the below cell
 
===Making fields optional===
 
A row with a label but no data is not displayed. This allows for optional infobox contents. To make a field optional, use a parameter that defaults to an empty string, like so:


;Syntax:
<pre>
<pre>
|data5={{{population|}}}
{{infobox
| Box title    =
| image        = Example.jpg
| imagewidth  = [defaults to 250]
| caption      =
| Row 1 title  =
| Row 1 info  =
| Row 2 title  =
| Row 2 info  =
| Row 3 title  =
| Row 3 info  =
| Row 4 title  =
| Row 4 info  =
| Row 5 title  =
| Row 5 info  =  
| Row 6 title  =
| Row 6 info  =
| Row 7 title  =
| Row 7 info  =
| Row 8 title  =
| Row 8 info  =
| Row 9 title  =
| Row 9 info  =
| Row 10 title =
| Row 10 info  =
}}
</pre>
</pre>


For more complex fields with preformatted contents that would still be present if a parameter was unset, you can wrap it all in a simple "if" statement to make the whole thing vanish when not used. Example:
;Notes:
* Keeping the '''Box Title''' empty will result in displaying '''No title'''
* If you don't want to display image, just keep '''Image file Name''' and '''Image Size''' empty.
* Keeping the '''Row 1 title''' empty will result in displaying '''No title'''.
* Keeping the '''Row (any row) info''' empty will result in displaying '''No information'''.
* Keeping the '''Row (any below row 1) title''' empty will result in that row and the rest of the rows below it will not be displayed.
* Max row for information: 10 rows.


<pre>
;Sample output:
|data5= {{#if: {{{mass|}}} | {{{mass}}} kg}}
</pre>
 
===Examples===
{{Infobox
{{Infobox
|name        = Infobox/doc
|Box title   = Info Title
|bodystyle   =  
|image       = Example.jpg
|title       = Test Infobox
|imagewidth   = 120
|titlestyle   =  
|caption      = A flower
 
|Row 1 title  = Title row 1
|image        = [[File:example.png|200px|alt=Example alt text]]
|Row 1 info   = Info row 1
|imagestyle   =  
|Row 2 title  = Title row 2
|caption      = Caption for example.png
|Row 2 info  = Info row 2
|captionstyle =  
|Row 3 title = Title row 3
|headerstyle = background:#ccf;
|Row 3 info   = Info row 3
|labelstyle   = background:#ddf;
|Row 4 title  = Title row 4
|datastyle    =  
|Row 4 info  = Info row 4
 
|Row 5 title = Title row 5
|header1 = Header defined alone
|Row 5 info   = Info row 5
|label1 =  
|Row 6 title = Title row 6
|data1   =  
|Row 6 info   = Info row 6
|header2 =
|Row 7 title = Title row 7
|label2 = Label defined alone does not display (needs data, or is suppressed)
|Row 7 info   = Info row 7
|data2   =  
|Row 8 title = Title row 8
|header3 =
|Row 8 info   = Info row 8
|label3 =  
|Row 9 title = Title row 9
|data3   = Data defined alone
|Row 9 info   = Info row 9
|header4 = All three defined (header, label, data, all with same number)
|Row 10 title = Title row 10
|label4 = does not display (same number as a header)
|Row 10 info  = Info row 10
|data4   = does not display (same number as a header)
|header5 =
|label5 = Label and data defined (label)
|data5   = Label and data defined (data)
 
|belowstyle = background:#ddf;
|below = Below text
}}
}}
Complete Infobox:<br />
<code>
'''<nowiki>{{</nowiki>Infobox'''<br />
'''|'''Box title    = Info Title<br />
'''|'''image        = Example.jpg<br />
'''|'''imagewidth  = 120<br />
'''|'''caption      = A flower<br />
'''|'''Row 1 title  = Title row 1<br />
'''|'''Row 1 info  = Info row 1<br />
'''|'''Row 2 title  = Title row 2<br />
'''|'''Row 2 info  = Info row 2<br />
'''|'''Row 3 title  = Title row 3<br />
'''|'''Row 3 info  = Info row 3<br />
'''|'''Row 4 title  = Title row 4<br />
'''|'''Row 4 info  = Info row 4<br />
'''|'''Row 5 title  = Title row 5<br />
'''|'''Row 5 info  = Info row 5<br />
'''|'''Row 6 title  = Title row 6<br />
'''|'''Row 6 info  = Info row 6<br />
'''|'''Row 7 title  = Title row 7<br />
'''|'''Row 7 info  = Info row 7<br />
'''|'''Row 8 title  = Title row 8<br />
'''|'''Row 8 info  = Info row 8<br />
'''|'''Row 9 title  = Title row 9<br />
'''|'''Row 9 info  = Info row 9<br />
'''|'''Row 10 title = Title row 10<br />
'''|'''Row 10 info  = Info row 10<br />
'''<nowiki>}}</nowiki>'''
</code>


<pre style="overflow:auto">{{Infobox
<br style="clear:both; margin-bottom:3em;"/>
|name        = Infobox/doc
|bodystyle    =
|title        = Test Infobox
|titlestyle  =
 
|image        = [[File:example.png|200px|alt=Example alt text]]
|imagestyle  =
|caption      = Caption for example.png
|captionstyle =
|headerstyle  = background:#ccf;
|labelstyle  = background:#ddf;
|datastyle    =
 
|header1 = Header defined alone
|label1  =
|data1  =
|header2 =
|label2  = Label defined alone does not display (needs data, or is suppressed)
|data2  =
|header3 =
|label3  =
|data3  = Data defined alone
|header4 = All three defined (header, label, data, all with same number)
|label4  = does not display (same number as a header)
|data4  = does not display (same number as a header)
|header5 =
|label5  = Label and data defined (label)
|data5  = Label and data defined (data)
 
|belowstyle = background:#ddf;
|below = Below text
}}</pre>
 
Notice how when a label is defined without an accompanying data cell the row doesn't appear in the displayed infobox, and when a header is defined on the same row as a data cell all of them are displayed.
 
{{clear}}
For this example, {{nowrap|bodystyle &#0061; width:20em;}} and {{nowrap|labelstyle &#0061; width:33%;}}


{{Infobox
{{Infobox
|bodystyle  = width:20em;
|Box title    = Info Title
|name        = Infobox/doc
|Row 1 title  = Title row 1
|title      = Test Infobox
|Row 1 info  = Info row 1
|titlestyle =  
|Row 2 title = Title row 2
|headerstyle =  
|Row 2 info  = Info row 2
|labelstyle = width:33%
|Row 3 title = Title row 3
|datastyle   =  
|Row 3 info   = Info row 3
 
|Row 4 title  = Title row 4
|header1 =  
|Row 4 info  = Info row 4
|label1 = Label 1
|Row 5 title = Title row 5
|data1   = Data 1
|Row 5 info   = Info row 5
|header2 =
|Row 6 title = Title row 6
|label2 = Label 2
|Row 6 info   = Info row 6
|data2   = Data 2
|Row 7 title = Title row 7
|header3 =
|Row 7 info   = Info row 7
|label3 = Label 3
|Row 8 title = Title row 8
|data3   = Data 3
|Row 8 info   = Info row 8
|header4 = Header 4
|Row 9 title = Title row 9
|label4 =  
|Row 9 info   = Info row 9
|data4   =  
|Row 10 title = Title row 10
|header5 =
|Row 10 info  = Info row 10
|label5 = Label 5
|data5   = Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
 
|belowstyle =  
|below = Below text
}}
}}
<pre style="overflow: auto">
Infobox '''Image''' omitted :<br />
{{Infobox
<code>
|bodystyle  = width:20em;
'''<nowiki>{{</nowiki>Infobox'''<br />
|name        = Infobox/doc
'''|'''Box title    = Info Title<br />
|title      = Test Infobox
'''|'''Row 1 title  = Title row 1<br />
|titlestyle =  
'''|'''Row 1 info  = Info row 1<br />
|headerstyle =  
'''|'''Row 2 title = Title row 2<br />
|labelstyle = width:33%
'''|'''Row 2 info  = Info row 2<br />
|datastyle   =  
'''|'''Row 3 title = Title row 3<br />
 
'''|'''Row 3 info   = Info row 3<br />
|header1 =  
'''|'''Row 4 title  = Title row 4<br />
|label1 = Label 1
'''|'''Row 4 info  = Info row 4<br />
|data1   = Data 1
'''|'''Row 5 title = Title row 5<br />
|header2 =  
'''|'''Row 5 info   = Info row 5<br />
|label2  = Label 2
'''|'''Row 6 title  = Title row 6<br />
|data2  = Data 2
'''|'''Row 6 info  = Info row 6<br />
|header3 =  
'''|'''Row 7 title  = Title row 7<br />
|label3 = Label 3
'''|'''Row 7 info  = Info row 7<br />
|data3   = Data 3
'''|'''Row 8 title = Title row 8<br />
|header4 = Header 4
'''|'''Row 8 info   = Info row 8<br />
|label4 =  
'''|'''Row 9 title = Title row 9<br />
|data4   =  
'''|'''Row 9 info   = Info row 9<br />
|header5 =  
'''|'''Row 10 title = Title row 10<br />
|label5 = Label 5
'''|'''Row 10 info = Info row 10<br />
|data5  = Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
'''<nowiki>}}</nowiki>'''
</code>


|belowstyle =  
<br style="clear:both; margin-bottom:3em;"/>
|below = Below text
}}
</pre>
{{clear}}


===Embedding===
One infobox template can be embedded into another using the {{para|child}} parameter.  This feature can be used to create a modular infobox, or to create more well defined logical sections.
{{Infobox
{{Infobox
| title = Top level title
|Box title   = Info Title
| data1 = {{Infobox
|Row 1 title  = Title row 1
   | child = yes
|Row 1 info   = Info row 1
  | title = First subsection
|Row 2 title = Title row 2
   | label1= Label 1.1
|Row 2 info   = Info row 2
   | data1 = Data 1.1
|Row 3 title  = Title row 3
|Row 3 info   = Info row 3
}}
}}
| data2 = {{Infobox
Infobox '''Image''' omitted and displaying only 3 rows of information:<br />
  | child = yes
<code>
  | title = Second subsection
'''<nowiki>{{</nowiki>Infobox'''<br />
  | label1= Label 2.1
'''|'''Box title   = Info Title<br />
  | data1 = Data 2.1
'''|'''Row 1 title  = Title row 1<br />
}}
'''|'''Row 1 info   = Info row 1<br />
|belowstyle =
'''|'''Row 2 title = Title row 2<br />
|below = Below text
'''|'''Row 2 info   = Info row 2<br />
}}
'''|'''Row 3 title  = Title row 3<br />
<pre style="overflow:auto">
'''|'''Row 3 info  = Info row 3<br />
{{Infobox
'''<nowiki>}}</nowiki>'''
| title = Top level title
</code>
| data1 = {{Infobox
  | child = yes
  | title = First subsection
  | label1= Label 1.1
  | data1 = Data 1.1
}}
| data2 = {{Infobox
  | child = yes
  | title = Second subsection
  | label1= Label 2.1
  | data1 = Data 2.1
}}
|belowstyle =
|below = Below text
}}
</pre>
Note, in the examples above, the child infobox is placed in a <code>data</code> field, not a <code>header</code> field.  The title will be enclosed in {{tag|b}} bold tags, which can create a "double bolding effect" in some browsers if the child infobox is placed in a <code>header</code> field.  To place the child infobox in a header field and avoid the double bolding effect, use
{{Infobox
| title = Top level title
| header1 = First subsection
  {{Infobox
  | child = yes
  | label1= Label 1.1
  | data1 = Data 1.1
}}
| header2 = Second subsection
  {{Infobox
  | child = yes
  | label1= Label 2.1
   | data1 = Data 2.1
}}
|belowstyle =
|below = Below text
}}
<pre style="overflow:auto">
{{Infobox
| title = Top level title
| header1 = First subsection
  {{Infobox
  | child = yes
  | label1= Label 1.1
  | data1 = Data 1.1
}}
| header2 = Second subsection
  {{Infobox
  | child = yes
  | label1= Label 2.1
   | data1 = Data 2.1
}}
|belowstyle =  
|below = Below text
}}
</pre>


==Full blank declaration==
<br style="clear:both; margin-bottom:3em;"/>
(Note: the template currently handles up to 99 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.)


<pre style="overflow:auto;">
{{Infobox
{{Infobox
|name        = {{subst:PAGENAME}}
|Box title   = Info Title
|bodystyle   =  
|Row 1 title  = Title row 1
|title       =
|Row 1 info   = Info row 1
|titlestyle  =
|Row 2 title = Title row 2
|above        =
|Row 2 info   = Info row 2
|abovestyle  =
|Row 3 title = Title row 3
 
|Row 3 info   = Info row 3
|imagestyle  =
|Row 4 info   = Info row 4
|captionstyle =
|Row 5 title = Title row 5
 
|Row 5 info   = Info row 5
|image        =
|Row 6 title = Title row 6
|caption      =
|Row 6 info   = Info row 6
|image2      =
}}
|caption2    =
Infobox '''Image''' and '''title row 4''' omited:<br />
 
Result: Row 4, 5, and 6 will not be displayed.<br />
|headerstyle =  
<code>
|labelstyle   =  
'''<nowiki>{{</nowiki>Infobox'''<br />
|datastyle    =
'''|'''Box title   = Info Title<br />
 
'''|'''Row 1 title = Title row 1<br />
|header1 =  
'''|'''Row 1 info   = Info row 1<br />
|label1   =  
'''|'''Row 2 title = Title row 2<br />
|data1    =
'''|'''Row 2 info   = Info row 2<br />
|header2 =  
'''|'''Row 3 title = Title row 3<br />
|label2   =  
'''|'''Row 3 info   = Info row 3<br />
|data2    =
'''|'''Row 4 info   = Info row 4<br />
|header3  =
'''|'''Row 5 title = Title row 5<br />
|label3   =  
'''|'''Row 5 info   = Info row 5<br />
|data3    =
'''|'''Row 6 title = Title row 6<br />
|header4 =  
'''|'''Row 6 info   = Info row 6<br />
|label4   =  
'''<nowiki>}}</nowiki>'''
|data4    =
</code>
|header5 =  
|label5   =  
|data5    =
|header6  =
|label6  =
|data6    =
|header7  =
|label7  =
|data7   =  
|header8 =  
|label8   =  
|data8    =
|header9 =  
|label9   =  
|data9    =
|header10 =
|label10 =  
|data10   =  
|header11 =
|label11  =
|data11   =  
|header12 =
|label12 =  
|data12   =  
|header13 =
|label13 =  
|data13   =  
|header14 =
|label14  =
|data14  =
|header15 =
|label15  =
|data15  =
|header16 =
|label16  =
|data16  =
|header17 =
|label17  =
|data17  =
|header18 =
|label18  =
|data18  =
|header19 =
|label19  =
|data19  =
|header20 =
|label20  =
|data20  =
 
|belowstyle =
|below =
}}</pre>


==See also==
==See also==
* {{tl|start infobox page}}
* {{tl|infobox3cols}}
=== See also ===
* {{tl|start infobox page}}
* {{tl|start infobox page}}
* {{tl|infobox3cols}}
* {{tl|infobox3cols}}

Latest revision as of 04:10, 12 February 2016

This is a documentation subpage for Template:Infobox.
It contains usage information, categories and other content that is not part of the original template page.

Description:

  • This template produces an infobox-style template.
  • You may want to copy and modify this to create a specific infobox (e.g. character infobox).
  • This template requires parser functions to be enabled (Wikia default: on).
Syntax
{{infobox
| Box title    = 
| image        = Example.jpg
| imagewidth   = [defaults to 250]
| caption      = 
| Row 1 title  = 
| Row 1 info   = 
| Row 2 title  = 
| Row 2 info   = 
| Row 3 title  = 
| Row 3 info   = 
| Row 4 title  = 
| Row 4 info   = 
| Row 5 title  = 
| Row 5 info   = 
| Row 6 title  = 
| Row 6 info   = 
| Row 7 title  = 
| Row 7 info   = 
| Row 8 title  = 
| Row 8 info   = 
| Row 9 title  = 
| Row 9 info   = 
| Row 10 title = 
| Row 10 info  = 
}}
Notes
  • Keeping the Box Title empty will result in displaying No title
  • If you don't want to display image, just keep Image file Name and Image Size empty.
  • Keeping the Row 1 title empty will result in displaying No title.
  • Keeping the Row (any row) info empty will result in displaying No information.
  • Keeping the Row (any below row 1) title empty will result in that row and the rest of the rows below it will not be displayed.
  • Max row for information: 10 rows.
Sample output
Info Title

A flower

Family

Info row 1

{{{Status}}}

Status

Complete Infobox:
{{Infobox
|Box title = Info Title
|image = Example.jpg
|imagewidth = 120
|caption = A flower
|Row 1 title = Title row 1
|Row 1 info = Info row 1
|Row 2 title = Title row 2
|Row 2 info = Info row 2
|Row 3 title = Title row 3
|Row 3 info = Info row 3
|Row 4 title = Title row 4
|Row 4 info = Info row 4
|Row 5 title = Title row 5
|Row 5 info = Info row 5
|Row 6 title = Title row 6
|Row 6 info = Info row 6
|Row 7 title = Title row 7
|Row 7 info = Info row 7
|Row 8 title = Title row 8
|Row 8 info = Info row 8
|Row 9 title = Title row 9
|Row 9 info = Info row 9
|Row 10 title = Title row 10
|Row 10 info = Info row 10
}}


Info Title

Family

Info row 1

{{{Status}}}

Status

Infobox Image omitted :
{{Infobox
|Box title = Info Title
|Row 1 title = Title row 1
|Row 1 info = Info row 1
|Row 2 title = Title row 2
|Row 2 info = Info row 2
|Row 3 title = Title row 3
|Row 3 info = Info row 3
|Row 4 title = Title row 4
|Row 4 info = Info row 4
|Row 5 title = Title row 5
|Row 5 info = Info row 5
|Row 6 title = Title row 6
|Row 6 info = Info row 6
|Row 7 title = Title row 7
|Row 7 info = Info row 7
|Row 8 title = Title row 8
|Row 8 info = Info row 8
|Row 9 title = Title row 9
|Row 9 info = Info row 9
|Row 10 title = Title row 10
|Row 10 info = Info row 10
}}


Info Title

Family

Info row 1

{{{Status}}}

Status

Infobox Image omitted and displaying only 3 rows of information:
{{Infobox
|Box title = Info Title
|Row 1 title = Title row 1
|Row 1 info = Info row 1
|Row 2 title = Title row 2
|Row 2 info = Info row 2
|Row 3 title = Title row 3
|Row 3 info = Info row 3
}}


Info Title

Family

Info row 1

{{{Status}}}

Status

Infobox Image and title row 4 omited:
Result: Row 4, 5, and 6 will not be displayed.
{{Infobox
|Box title = Info Title
|Row 1 title = Title row 1
|Row 1 info = Info row 1
|Row 2 title = Title row 2
|Row 2 info = Info row 2
|Row 3 title = Title row 3
|Row 3 info = Info row 3
|Row 4 info = Info row 4
|Row 5 title = Title row 5
|Row 5 info = Info row 5
|Row 6 title = Title row 6
|Row 6 info = Info row 6
}}