Template:Infobox

From Rosecord Wiki
Revision as of 15:47, 16 January 2024 by Ame (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

{{#switch:

 {{#if:
 | {{{demospace}}}    
 | {{#ifeq:Template|Template
   | template
   | other
   }}
 }}

| template = {{#ifeq:Infobox|Infobox||{{#ifeq:Template:Str left|Infobox|[[Category:Infobox templates|Template:Remove first word]]}}}} | other | #default =

}}

This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others being used for microformats.

To flag an infobox as containing hCard information, for example, add the following parameter:

<syntaxhighlight lang="wikitext" style="overflow:auto">

| bodyclass = vcard

</syntaxhighlight>

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
| class2 = org
| class3 = tel

</syntaxhighlight>

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

See Wikipedia:WikiProject Microformats for more information on adding microformat information to Wikipedia, and microformat for more information on microformats in general.

Examples

Notice how the row doesn't appear in the displayed infobox when a label is defined without an accompanying data cell, and how all of them are displayed when a header is defined on the same row as a data cell. Also notice that subheaders are not bold by default like the headers used to split the main data section, because this role is meant to be for the above cell :

Test Infobox
Above text
Subheader above image
Second subheader
Example alt text
Caption displayed below File:Example-serious.jpg
Header defined alone
Data defined alone
All three defined (header, label, data, all with same number)
Label and data defined (label)Label and data defined (data)
Below text

<syntaxhighlight lang="wikitext">

Test Infobox
Above text
Subheader above image
Second subheader
Example alt text
Caption displayed below File:Example-serious.jpg
Header defined alone
Data defined alone
All three defined (header, label, data, all with same number)
Label and data defined (label)Label and data defined (data)
Below text

</syntaxhighlight> For this example, the |{{SAFESUBST:#if:bodystyle|bodystyle=}} and |{{SAFESUBST:#if:labelstyle|labelstyle=}} parameters are used to adjust the infobox width and define a default width for the column of labels:

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

<syntaxhighlight lang="wikitext">

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

</syntaxhighlight>

Embedding

One infobox template can be embedded into another using the |{{SAFESUBST:#if:child|child=}} parameter. This feature can be used to create a modular infobox, or to create better-defined logical sections. Long ago, it was necessary to use embedding in order to create infoboxes with more than 99 rows; but nowadays there's no limit to the number of rows that can be defined in a single instance of {{infobox}}.

Top level title
First subsection
Label 1.1Data 1.1
Second subsection
Label 2.1Data 2.1
Below text

<syntaxhighlight lang="wikitext" style="overflow:auto">

Top level title
First subsection
Label 1.1Data 1.1
Second subsection
Label 2.1Data 2.1
Below text

</syntaxhighlight>

Note, in the examples above, the child infobox is placed in a data field, not a header 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

Top level title
First subsection
Label 1.1Data 1.1
Second subsection
Label 2.1Data 2.1
Below text

<syntaxhighlight lang="wikitext" style="overflow:auto">

Top level title
First subsection
Label 1.1Data 1.1
Second subsection
Label 2.1Data 2.1
Below text

</syntaxhighlight>

or,

Top level title
First subsection
Label 1.1Data 1.1
Second subsection
Label 2.1Data 2.1
Below text

<syntaxhighlight lang="wikitext" style="overflow:auto">

Top level title
First subsection
Label 1.1Data 1.1
Second subsection
Label 2.1Data 2.1
Below text

</syntaxhighlight>

Note that omitting the |{{SAFESUBST:#if:title|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 |{{SAFESUBST:#if:rowstyleN|rowstyleN=}}display: none, replacing N with the data/header number.

Wikipedia:WikiProject Infoboxes/embed includes some links to Wikipedia articles which include infoboxes embedded within other infoboxes.

Subboxes

An alternative method for embedding is to use |{{SAFESUBST:#if:subbox|subbox=}}yes, which removes the outer border from the infobox, but preserves the interior structure. One feature of this approach is that the parent and child boxes need not have the same structure, and the label and data fields are not aligned between the parent and child boxes because they are not in the same parent table.

Main 1
Main 2
Sub 3-1
Sub 3-2
Label 3-3Data 3-3
Label 4-1Data 4-1
Label 5Data 5
Main 6

<syntaxhighlight lang="wikitext" style="overflow:auto">

Main 1
Main 2
Sub 3-1
Sub 3-2
Label 3-3Data 3-3
Label 4-1Data 4-1
Label 5Data 5
Main 6

</syntaxhighlight>

Similar embedding techniques may be used within content parameters of some other templates generating tables (such as Sidebar) :

<syntaxhighlight lang="wikitext" style="overflow:auto">

</syntaxhighlight>

Note that the default padding of the parent data cell containing each subbox is still visible, so the subboxes are slightly narrower than the parent box and there's a higher vertical spacing between standard cells of the parent box than between cells of distinct subboxes.

Controlling line-breaking in embedded bulletless lists

Template {{nbsp}} may be used with {{wbr}} and {{nowrap}} to control line-breaking in bulletless lists embedded in infoboxes (e.g. cast list in {{Infobox film}}), to prevent wrapped long entries from being confused with multiple entries. See Template:Wbr/doc#Controlling line-breaking in infoboxes for details.

Full blank syntax

(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"> Lua error in Module:Navbar at line 58: Invalid title {{subst:PAGENAME}}.

</syntaxhighlight>

Infoboxes and user style

Users can have user CSS that hides any infoboxes in their own browsers.

To hide all infoboxes, add the following to Special:MyPage/common.css (for all skins, or Special:MyPage/skin.css for just the current skin), on a line by itself: <syntaxhighlight lang="css">div.mw-parser-output .infobox { display: none; }</syntaxhighlight>

Alternatively, you can add the following code to your common.js or into a browser user script that is executed by an extension like Greasemonkey:

<syntaxhighlight lang="js">$('.infobox').hide();</syntaxhighlight>

Be aware that although{{#if:||, per WP:Manual of Style/Infoboxes,}} all information in an infobox ideally should also be found in the main body of an article, there isn't perfect compliance with this guideline. For example, the full taxonomic hierarchy in {{Taxobox}}, and the OMIM and other medical database codes of {{Infobox disease}} are often not found in the main article content. The infobox is also often the location of the most significant, even only, image in an article. There is a userscript which removes infoboxes but moves the images contained to separate thumbnails: User:Maddy from Celeste/disinfobox.js.

Porting to other MediaWikis

The infobox template requires the Scribunto and TemplateStyles extensions. WikiProject Transwiki has a version of this template that has been modified to work on other MediaWikis.

TemplateData

{{#if:|{{#switch:
|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AInfobox%7CInfobox%7CInfobox%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}}
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Infobox|Template:Infobox|this template}} in articles{{#ifeq:{{safesubst:#switch: y

|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}}.

|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AInfobox%7CInfobox%7CInfobox%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}}
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y

|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}}

|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AInfobox%7CInfobox%7CInfobox%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}}
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|no|P|p}}arameter usage report] for {{#if:Infobox|Template:Infobox|Template:Infobox}}{{#ifeq:{{safesubst:#switch: y

|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}}.

|#default=[1]{{#ifeq:{{safesubst:#switch: y
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}} }}|This is the {{#if:|TemplateData|TemplateData}} for this template used by TemplateWizard, VisualEditor and other tools. {{#switch:

|=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AInfobox%7CInfobox%7CInfobox%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}}
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|no|S|s}}ee a monthly parameter usage report] for {{#if:Infobox|Template:Infobox|this template}} in articles{{#ifeq:{{safesubst:#switch: y

|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}}.

|None|none=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AInfobox%7CInfobox%7CInfobox%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}}
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|no|P|p}}arameter usage report]{{#ifeq:{{safesubst:#switch: y

|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}}

|for|For=[https://bambots.brucemyers.com/TemplateParam.php?wiki=enwiki&template=%7B%7B%23if%3AInfobox%7CInfobox%7CInfobox%7D%7D {{#ifeq:{{safesubst:#switch: {{{lc}}}
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|no|P|p}}arameter usage report] for {{#if:Infobox|Template:Infobox|Template:Infobox}}{{#ifeq:{{safesubst:#switch: y

|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}}.

|#default=[2]{{#ifeq:{{safesubst:#switch: y
|no
|n
|f
|false
|off
|0        = no
|         = no
|¬        = no
|yes
|y
|t
|true
|on
|1        = yes
|#default = no

}}|yes| based on {{#if:Infobox|its|this}} TemplateData}} }}}}

TemplateData for Infobox

{{#switch:

 {{#if:
 | {{{demospace}}}    
 | {{#ifeq:Template|Template
   | template
   | other
   }}
 }}

| template = {{#if:{{#ifeq:Infobox|sandbox|1}}{{#ifeq:Infobox|doc|1}}||

}} | other | #default = }} <templatedata> { "description": "This template is intended as a meta template, a template used for constructing other templates. In general, it is not meant for use directly in an article but can be used on a one-off basis if required.", "format": "Template:\n\n", "params": { "title": { "label": "Title", "description": "Title displayed above the infobox", "type": "string", "suggested": true }, "image": { "label": "Image", "description": "Image illustrating the topic. Use full image syntax.", "type": "content", "suggested": true, "example": "Example alt text" }, "caption": { "label": "Caption", "description": "caption for the image", "type": "content", "suggested": true } }, "paramOrder": [ "title", "image", "caption" ] } </templatedata>


Tracking categories

See also

{{#if:{{#ifeq:Infobox|sandbox|1}}{{#ifeq:Infobox|doc|1}}||

}}