Personal tools


From Arcanum Illyria

Jump to: navigation, search

This template is intended as a meta-template: a template used for constructing other templates. It is not meant for use directly in an article, but for supporting more simplified special-purpose templates. See w:Help:Infobox for an introduction to infoboxes and information on how they are constructed. See Category:Databox templates for available specific templates appropriate for direct use. Databox is a simplified version of Wikipedia's infobox optimized for use here.



Databox accepts a series of ordered key-value pairs, each of which defines a row on the table that can contain either a header, a label/data pair, or just a data cell. These are mutually exclusive states so if you define a row with both a header and a label/data pair, the label/data pair is ignored.

To insert an image somewhere other than at the top of the databox, or to insert freeform data, use a row with only a data field.

Number ranges

To allow flexibility when the layout of an databox is changed, it may be helpful when developing an databox 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:

|header3  = Section 1
|label5   = Label A
|data5    = Data B
|label7   = Label C
|data7    = Data C
|header10 = Section 2
|label12  = Label D
|data12   = Data D


View/discuss/edit links

The template page name that the "view/discuss/edit" links should point to. You can use {{subst:PAGENAME}}. If this parameter is omitted the view/discuss/edit links will not be displayed.


Text in caption over databox
Subheader of the databox
(the rest of the databox goes here)
Text in uppermost cell of databox
Subheader of the databox
2nd subheader of the databox
(the rest of the databox goes here)

There are two different ways to put a title on an databox. One contains the title inside the databox's border, the other puts it on top as a caption. You can use both of them together if you like, or just one or the other, or even neither (though this is not recommended).

Text to put in the caption over top of the table.
Text to put within the uppermost cell of the table.

Optional content

subheader, subheader2 
additional title fields which fit between {{{title}}} and {{{above}}}.
image, image2 
images to display at the top of the template. Use full image syntax, for example [[File:resource-saddle-xl.png|200px|alt=Example alt text]]. Image is centered in the box with a little whitespace above it.
caption1, caption2 
Text to put underneath the images.
Text to use as a header in row n.
Text to use as a label in row n.
Text to display as data in row n.
Text to put in the bottom cell. The bottom cell is intended for footnotes, see-also, and other such information.

Note: headers, labels and data items with the same n-value are mutually exclusive; only the header will be displayed. See the rendering of header4, label4, and data4 in the examples section below.

Custom styling

This wiki uses static CSS with databoxes for optimal efficiency and to maintain databox style more consistent with the overall theme of the wiki. Only basic necessities will be provided to adjust databoxes from the default format, as contextually appropriate.

This parameter is inserted into the "class" attribute for the databox as a whole, allowing the databox to be statically tweaked for special purposes. Only classes appropriately defined by the current theme will have any effect, and any such classes will already be accompanied by an appropriate special-purpose template which should be used instead of this one. Since only the theme administrator can effectively manage these customizations, current listing of valid classes will not be maintained here.
Since a single standard width for the whole box may not always work, it can be specified by this parameter. If absent, a standard default width will be used.
Similar to width, but specifies the width of labels in label-data pairs. If unspecified, labelwidth is left up to the browser to balance according to HTML flow.

Making fields optional

A row with a label but no data is not displayed. This allows for the easy creation of optional databox content rows. To make a row optional use a parameter that defaults to an empty string, like so:

|label5 = Population
|data5  = {{{population|}}}

This way if an article doesn't define the population parameter in its databox the row won't be displayed.

For more complex fields with pre-formated 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'":

|label6 = Mass
|data6  = {{#if:{{{mass|}}}|{{{mass}}} kg}}

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:

|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|}}}

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.


Test Databox
Example alt text
Caption for Resource-saddles-xl.png
Header defined alone
Data defined alone
All three defined (header)
Label and data defined (label) Label and data defined (data)
Below text
|name         = Databox
|class        = resource
|title        = Test Databox
|labelwidth   = 40%

|image        = [[File:Resource-saddles-xl.png|160px|alt=Example alt text]]
|caption      = Caption for Resource-saddle-xl.png

|header1 = Header defined alone
|label1  = 
|data1   = 
|header2 = 
|label2  = Label defined alone
|data2   = 
|header3 =
|label3  = 
|data3   = Data defined alone
|header4 = All three defined (header)
|label4  = All three defined (label)
|data4   = All three defined (data)
|header5 =
|label5  = Label and data defined (label)
|data5   = Label and data defined (data)

|below = Below text

Notice how when a label is defined without an accompanying data cell the row doesn't appear in the displayed databox, and when a header is defined on the same row as a data cell the header takes precedence.

Test Databox
Label 1 Data 1
Label 2 Data 2
Label 3 Data 3
Header 4
Label 5 Data 5: Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
Below text

Full blank syntax

(Note: the template currently handles up to 80 rows; only 20 are included here since databoxes larger than that will be relatively rare. Just extend the numbering as needed.

|name         = {{subst:PAGENAME}}
|class        =
|title        = 
|labelwidth   = 
|above        = 

|subheader    =
|subheader2   =

|image        = 
|caption      = 
|image2       = 
|caption2     = 

|header1  = 
|label1   = 
|data1    = 
|header2  = 
|label2   = 
|data2    = 
|header3  = 
|label3   = 
|data3    = 
|header4  = 
|label4   = 
|data4    = 
|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   = 
|below =