Wikipedia:Dynamic infobox templates

From Wikipedia, the free encyclopedia

This page is part of the Manual of Style, and is considered a guideline for Wikipedia. The consensus of many editors formed the conventions described here, and Wikipedia articles should heed these guidelines. Before making any major changes to these guidelines, please use the discussion page to ensure that your changes reflect consensus.
Shortcut:
WP:DIT

Infobox templates are a broad class of templates commonly used at the top of an article to present certain summary or overview information about the subject. In theory, the fields in an infobox should be consistent across every article using it; in practice, however, this is rarely the case, for a number of reasons. When this occurs, the infobox templates should be designed to dynamically adapt themselves to the absence or presence of particular fields.

Contents

[edit] Causes of inconsistency

A number of factors can cause inconsistency in available summary information for a particular type of article:

Historical incompleteness 
Certain desired information may simply have been lost over time. For example, an infobox describing a modern bank may provide certain financial information that would be unavailable for a medieval one.
Hierarchical inconsistency 
Infoboxes that indicate hierarchical relationships may have subtly different requirements depending on where in the hierarchy the subject of the article is located. For example, an infobox for corporations will be different between an article describing a parent company and indicating its subsidiaries and an article describing a subsidiary and indicating its parent.
Feature inconsistency 
Items within a single set may have optional features that would commonly be listed in an infobox. For example, an infobox for an article about a university may include a motto; but not all universities have them.
Lack of information 
Some items in infoboxes may not be readily available or not available at all, such as the producers of an album or film. In these cases it is better to provide available information while concealing fields for which information may not be available.

[edit] Why dynamic templates?

While there are several alternatives to dynamic infoboxes, such as using multiple (forked) templates or leaving fields blank, they should be avoided, for a number of reasons:

Readers greatly outnumber editors 
The most important group to consider are the casual readers of Wikipedia, who will never do any significant editing. Infobox templates that contain many blank fields, question marks, or "Unknown"s present an unprofessional appearance, diminishing Wikipedia's reputation as a high-quality encyclopedia.
Article editors greatly outnumber template editors 
The average editor will merely use templates without making changes to them. To make things easier for them, we should aim to minimize the number of different templates they must be familiar with; creating multiple forks of templates is therefore undesirable.

[edit] General advice

The availability of optional fields does not mean that all fields should be made optional, however, nor that large numbers of rarely used fields should be added without regard for the overall layout and ease-of-use of the infobox template. In some cases, the markup for the field still needs to be downloaded even if it is not displayed. Creating overly long templates with a number of irrelevant fields is not recommended.

As you design an infobox template, consider the following questions:

Is the field of value? 
How important is the field to the articles that will use the infobox? Is it summary information, or more extended detail that may be better placed within the body of an article?
Will the field be relevant to many of the articles that will use the infobox? 
If the field is relevant to very few articles, it should probably not be included at all. Conversely, very common fields may be included—and made optional—even if they are not applicable to a few of the articles in question.
How likely is the field to be empty? 
Any field that might reasonably be empty should probably be optional. However, a field that is usually empty may not be particularly useful or relevant.

[edit] Implementations

[edit] Conditional templates

Main article: m:ParserFunctions

Special "templates" that selectively show or hide particular content (such as table rows) within an infobox based on the value of one or more template parameters.

<!--
-->{{#if:{{{party|}}}|<tr><th>Political party</th><td>{{{party|}}}</td></tr>|}}<!--
-->

[edit] Name-resolved meta-templates

Several sub-templates (or even independent templates) with a common name prefix. They are included in an infobox based on the value of a particular parameter, which acts as the name suffix. For example, we create {{Infobox Ship/Military}} and {{Infobox Ship/Civilian}} and use {{Infobox Ship/{{{type}}}}}. Using |type=Military in an article causes {{Infobox Ship/Military}} to be used.

[edit] Multi-part infoboxes

Rather than having each field correspond to a parameter on one template, the infobox consists of an individual sub-template for each field; see, for example, Template:Taxobox.