Template:Infobox: Difference between revisions

From Kerbal Powers Wiki
Jump to navigation Jump to search
No edit summary
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 6: Line 6:
 
{{Infobox/SectionHeader|section={{{example_section}}}}}
 
{{Infobox/SectionHeader|section={{{example_section}}}}}
 
{{Infobox/Item|key=Sample data|value={{{example_data}}}}}
 
{{Infobox/Item|key=Sample data|value={{{example_data}}}}}
  +
{{Infobox/Vertical Item|key=Vertical sample|value={{{example_data_2}}}}}
  +
{{Infobox/Bar}}
  +
{{Infobox/Sound Item|key=Sample data|value=Helicopter-helicopter-parakofer-parakofer.mp3}}
  +
{{Infobox/Bar}}
  +
{{Infobox/Dual Illustration|left_file={{{illustration}}}|left_caption={{{caption}}}|right_file={{{illustration}}}|right_caption={{{caption}}}}}
  +
{{Infobox/Bar}}
  +
{{Infobox/Column}}
  +
{{Infobox/Three Column|leftValue={{{force_1_list}}}|centerValue={{{force_2_list}}}|rightValue={{{force_3_list}}}}}
  +
{{Infobox/Column|leftValue={{{force_1_list}}}|rightValue={{{force_2_list}}}}}
 
{{Infobox/end}}
 
{{Infobox/end}}
 
<nowiki /></includeonly>
 
<nowiki /></includeonly>
Line 34: Line 43:
 
{{Infobox
 
{{Infobox
 
| title = A second infobox
 
| title = A second infobox
| caption = Test
 
 
}}
 
}}
 
...and here, and it should appear directly below the previous one.
 
...and here, and it should appear directly below the previous one.
Line 58: Line 66:
 
** <code>key</code> : The (readable) label of an attribute, which should consist of a few, chosen words like "Type" or "Date of birth". Avoid long labels like "Date at which this aircraft experienced its first air battle over foreign territory", they tend to break the infobox's design by making it hard to read.
 
** <code>key</code> : The (readable) label of an attribute, which should consist of a few, chosen words like "Type" or "Date of birth". Avoid long labels like "Date at which this aircraft experienced its first air battle over foreign territory", they tend to break the infobox's design by making it hard to read.
 
** <code>value</code> : The value (content) of the attribute.
 
** <code>value</code> : The value (content) of the attribute.
  +
* [[Template:Infobox/Column|<code><nowiki>{{Infobox/Column|...}}</nowiki></code>]] :
 
* [[Template:Infobox/begin|<code><nowiki>{{Infobox/begin|...}}</nowiki></code>]] and [[Template:Infobox/end|<code><nowiki>{{Infobox/end}}</nowiki></code>]] : '''These are mandatory to any infobox''' and defines the beginning and end of an infobox. They ''must'' be respectively the first and last components of an infobox template. The following arguments can be used in <code><nowiki>{{Infobox/begin|...}}</nowiki></code>:
 
* [[Template:Infobox/begin|<code><nowiki>{{Infobox/begin|...}}</nowiki></code>]] and [[Template:Infobox/end|<code><nowiki>{{Infobox/end}}</nowiki></code>]] : '''These are mandatory to any infobox''' and defines the beginning and end of an infobox. They ''must'' be respectively the first and last components of an infobox template. The following arguments can be used in <code><nowiki>{{Infobox/begin|...}}</nowiki></code>:
 
** <code>nofloat</code> : When <code>nofloat</code> is set to <code>true</code>, the infobox ''will not'' float to the right and will instead remain in the document flow as a block element (text will break before and after it. Additionally it will appear centered on the page. When set to any other value, or not set at all, the infobox will use the normal "float to the right" behaviour.
 
** <code>nofloat</code> : When <code>nofloat</code> is set to <code>true</code>, the infobox ''will not'' float to the right and will instead remain in the document flow as a block element (text will break before and after it. Additionally it will appear centered on the page. When set to any other value, or not set at all, the infobox will use the normal "float to the right" behaviour.

Latest revision as of 15:22, 22 January 2024

You should not directly use this template, it serves as a base for other Infoboxes templates to inherit from. See this list of other infobox templates.


{{{title}}}

{{{illustration}}}
{{{caption}}}
{{{example_section}}}
Sample data {{{example_data}}}
Vertical sample
{{{example_data_2}}}


{{{illustration}}}
{{{caption}}}
{{{illustration}}}
{{{caption}}}

{{{leftValue}}} {{{rightValue}}}
{{{force_1_list}}} {{{force_2_list}}} {{{force_3_list}}}
{{{force_1_list}}} {{{force_2_list}}}


Example

Example

KP dark.png
Example infobox
Example section
Sample data Soap floats on water, but its efficiency at naval battles is yet to be proven
Vertical sample
{{{example_data_2}}}


KP dark.png
Example infobox
KP dark.png
Example infobox

{{{leftValue}}} {{{rightValue}}}
{{{force_1_list}}} {{{force_2_list}}} {{{force_3_list}}}
{{{force_1_list}}} {{{force_2_list}}}


The following markup will produce the output presented to the right of this paragraph :

{{Infobox
 | title = Example
 | illustration = [[File:KP dark.png]]
 | caption = Example infobox
 | example_section = Example section
 | example_data = Soap floats on water, but its efficiency at naval battles is yet to be proven
}}

Templates are floated to the right, which means they will appear in the document shifted to the right of the page, whilst being kept in the document flow (ie, text will wrap around them. Templates will "clear" off each other, and appear below the previous ones in the order they were added into the document flow. As an example, there is a template between here...

A second infobox

{{{illustration}}}
{{{caption}}}
{{{example_section}}}
Sample data {{{example_data}}}
Vertical sample
{{{example_data_2}}}


{{{illustration}}}
{{{caption}}}
{{{illustration}}}
{{{caption}}}

{{{leftValue}}} {{{rightValue}}}
{{{force_1_list}}} {{{force_2_list}}} {{{force_3_list}}}
{{{force_1_list}}} {{{force_2_list}}}

...and here, and it should appear directly below the previous one. This behaviour may sometimes cause problems with block elements (see the CSS display modes), as these elements typically will ignore floats and "slide" underneath them, whereas their content will behave normally and wrap around the floating element.

To solve that problem, or for readability and design, you will often find yourself in need of "pushing" the rest of the document's flow after a floating box. The Template:clr will do that for you, and is used by inserting {{clr}} at any point in your document. All content after that point will clear from all floating elements and will appear below them, like this paragraph.

Using, creating and modifying infoboxes

Usage

You should not directly use this template itself. Instead use other templates already created in Category:Infoboxes, or create a new one. This template serves as a framework to define common rules between all infoboxes and providing a root page for sub-templates defined below.

Sub-templates components

In order to ease the creation of infoboxes, this basic template is itself made of reusable components which can be reused in other templates. They are listed below, and may be used in your own templates. You can also create new ones.

  • {{Infobox/Header|...}} : This component defines the header title of an infobox (the "bold greyed" part at the top of an infobox). The following arguments can be used :
    • title : The title to display.
  • {{Infobox/Illustration|...}} : This component represents an image and it's associated caption which are usually used to illustrate an infobox. The following arguments can be used :
    • file : The picture to display (which can be uploaded or inserted using the editor's "Embed File" button)
    • caption : A caption for the picture
  • {{Infobox/SectionHeader|...}} : This component defines a section header, which helps grouping and separating attributes in an infobox. The following arguments can be used :
    • section : The new section's title
  • {{Infobox/Item|...}} : This is the basic "key-value" attribute of an infobox used to present a piece of data with a label. The following arguments can be used :
    • key : The (readable) label of an attribute, which should consist of a few, chosen words like "Type" or "Date of birth". Avoid long labels like "Date at which this aircraft experienced its first air battle over foreign territory", they tend to break the infobox's design by making it hard to read.
    • value : The value (content) of the attribute.
  • {{Infobox/Column|...}} :
  • {{Infobox/begin|...}} and {{Infobox/end}} : These are mandatory to any infobox and defines the beginning and end of an infobox. They must be respectively the first and last components of an infobox template. The following arguments can be used in {{Infobox/begin|...}}:
    • nofloat : When nofloat is set to true, the infobox will not float to the right and will instead remain in the document flow as a block element (text will break before and after it. Additionally it will appear centered on the page. When set to any other value, or not set at all, the infobox will use the normal "float to the right" behaviour.

Specifications

Generic floating infobox.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Titletitle

Title that appears at the top of the infobox.

Default
Infobox
Stringrequired
Illustrationillustration

A picture describing the subject.

Fileoptional
Captioncaption

A short descriptive text for the illustration.

Stringoptional
example_sectionexample_section

This is only used for demonstration purposes. Any children template inheriting from this one should remove this attribute.

Unknowndeprecated
example_dataexample_data

This is only used for demonstration purposes. Any children template inheriting from this one should remove this attribute.

Unknowndeprecated
nofloatnofloat

Setting any value to this parameter will make the infobox stop floating to the right.

Unknownoptional