Template:Infobox: Difference between revisions
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
<noinclude>{{Note|You should not directly use this template, it serves as a base for other Infoboxes templates to inherit from. See [[:Category:Infoboxes|this list of other infobox templates]].|warn}}</noinclude><nowiki /> |
<noinclude>{{Note|You should not directly use this template, it serves as a base for other Infoboxes templates to inherit from. See [[:Category:Infoboxes|this list of other infobox templates]].|warn}}</noinclude><nowiki /> |
||
+ | <includeonly><nowiki /> |
||
− | <includeonly><templatestyles src="Infobox/style.css"/><table class="infobox {{#ifeq: {{{nofloat|}}}|{{{nofloat}}}|nofloat|}}"><nowiki /> |
||
+ | {{Infobox/begin|nofloat={{{nofloat}}}}} |
||
{{Infobox/Header|title={{{title}}}}} |
{{Infobox/Header|title={{{title}}}}} |
||
{{Infobox/Illustration|file={{{illustration}}}|caption={{{caption}}}}} |
{{Infobox/Illustration|file={{{illustration}}}|caption={{{caption}}}}} |
||
{{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/end}} |
||
− | + | <nowiki /></includeonly> |
|
<noinclude> |
<noinclude> |
||
− | {{Infobox|nofloat= |
+ | {{Infobox|nofloat=true}} |
== Example == |
== Example == |
||
Line 56: | Line 58: | ||
** <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/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. |
||
{{clr}} |
{{clr}} |
Revision as of 01:47, 7 March 2021
{{{title}}}
|
|||||
---|---|---|---|---|---|
{{{illustration}}} | |||||
{{{caption}}} | |||||
{{{example_section}}} | |||||
Sample data | {{{example_data}}} |
Example
Example
|
|||||
---|---|---|---|---|---|
Example infobox | |||||
Example section | |||||
Sample data | Soap floats on water, but its efficiency at naval battles is yet to be proven |
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}}} | |||||
Test | |||||
{{{example_section}}} | |||||
Sample data | {{{example_data}}} |
...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/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
: Whennofloat
is set totrue
, 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.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Title | title | Title that appears at the top of the infobox.
| String | required |
Illustration | illustration | A picture describing the subject. | File | optional |
Caption | caption | A short descriptive text for the illustration. | String | optional |
example_section | example_section | This is only used for demonstration purposes. Any children template inheriting from this one should remove this attribute. | Unknown | deprecated |
example_data | example_data | This is only used for demonstration purposes. Any children template inheriting from this one should remove this attribute. | Unknown | deprecated |
nofloat | nofloat | Setting any value to this parameter will make the infobox stop floating to the right. | Unknown | optional |