Template:Infobox election/doc

From Chalo Chatu, Zambia online encyclopedia
Revision as of 08:14, 19 September 2025 by Chalochatu (talk | contribs) (Created page with "{{Documentation subpage}} {{High-risk|reason=Heavily used across election articles; changes affect many pages.}} = Template:Infobox election = This template builds a flexible infobox for election pages (presidential, parliamentary/legislative, by-elections, primaries). It supports up to nine parties/candidates in three blocks (1–3, 4–6, 7–9), optional turnout and progress bars, and up to four maps with captions. == Basic usage == Minimal example (presidential): <...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search
This is a documentation subpage for Template:Infobox election.
It contains usage information, categories and other content that is not part of the original template page.

Lua error in Module:High-use at line 164: attempt to call field 'main' (a nil value).

Template:Infobox election

This template builds a flexible infobox for election pages (presidential, parliamentary/legislative, by-elections, primaries). It supports up to nine parties/candidates in three blocks (1–3, 4–6, 7–9), optional turnout and progress bars, and up to four maps with captions.

Basic usage

Minimal example (presidential):

{{Infobox election
| election_name = 2021 Zambian general election
| country       = Zambia
| type          = presidential
| election_date = {{Start date|2021|8|12|df=yes}}
| vote_type     = Popular
| turnout       = 70.61%

| image1        = [[File:HH2022.png|130x130px]]
| nominee1      = [[Hakainde Hichilema]]
| running_mate1 = [[Mutale Nalumango]]
| party1        = United Party for National Development
| popular_vote1 = 2,852,348
| percentage1   = 59.02%

| image2        = [[File:Edgar Lungu, 26 july 2018 (cropped).jpg|130x130px]]
| nominee2      = [[Edgar Lungu]]
| running_mate2 = [[Nkandu Luo]]
| party2        = Patriotic Front (Zambia)
| popular_vote2 = 1,870,780
| percentage2   = 38.71%
}}

Nested (module) infoboxes (e.g., add a legislative block inside the main infobox) are supported via:

| module = {{Infobox legislative election
  | embed              = yes
  | election_name      = National Assembly election
  | seats_for_election = 156 of the 167 seats in the [[National Assembly of Zambia|National Assembly]]
  | majority_seats     = 85
  | leader1            = [[Hakainde Hichilema]]
  | party1             = United Party for National Development
  | seats1             = 82
  | leader2            = [[Edgar Lungu]]
  | party2             = Patriotic Front (Zambia)
  | seats2             = 59
}}

Key parameters

election_name
Display title of the election.
country
Country or jurisdiction (e.g., Zambia; use full page title if linking).
type
presidential, parliamentary, legislative, or by-election (drives certain labels).
election_date
Free text or  ().
vote_type
Defaults to Popular. Override if needed.
turnout
Display turnout text (plain text or with change indicator e.g., Increase 2 pp).

Previous / Next navigation

previous_election, previous_year
next_election, next_year
Builds the year links in the subheader if provided.

Progress bars (optional)

votes_counted, reporting, declared
Numbers or percents for status bars. Requires Template:Percentage bar. Also set:
last_update, time_zone
Timestamp/zone text appended after the bar.

Party/Candidate sets

Each set repeats with suffixes 1–3, 4–6, 7–9.

imageN
Candidate image wikitext (e.g., File:…).
nomineeN / candidateN / leaderN
Display name. Use one per candidate (nomineeN preferred).
running_mateN
For presidential/VP systems.
partyN
Party or alliance name.
popular_voteN, percentageN
Results figures per candidate/party.
seatsN, seats_beforeN, seats_afterN, seat_changeN
For legislative elections.
colorN / colourN
Hex or named color; if both are set, colorN takes priority.

Map images (optional)

Up to four maps may be shown.

map_image, map_caption, map_size (default 300px), map_alt
map2_image, map2_caption, map2_size, map2_alt
map3_image, map3_caption, map3_size, map3_alt
map4_image, map4_caption, map4_size, map4_alt
Alternatively, use map, map2, etc. to inject raw HTML/wikitext (advanced use).

Officeholders (before/after)

title
Office name (e.g., President; affects end labels).
before_election, before_party
after_election, after_party
posttitle
Override final label (e.g., President-elect). If ongoing = yes, wording adapts.

Other common fields

registered
Registered voters.
votes_for_election, needed_votes
For primary/convention style thresholds.
seats_for_election, majority_seats
For legislative elections.
opinion_polls
Page title for the polling article.

Styling

This template uses site CSS for infobox layout. For collapsible blocks used elsewhere, you may add:

.chalo-collapsible { border:1px solid #ddd; margin:0.2em 0; }
.chalo-collapsible-head { background:#f7f7f7; padding:0.3em; cursor:pointer; }
.chalo-collapsible-body { padding:0.4em 0.6em; display:block; }
.chalo-collapsible.collapsed .chalo-collapsible-body { display:none; }

Add to MediaWiki:Common.css.

Dependencies

Required (or adjust template to remove calls):

Nice to have (site hygiene):

Notes and constraints

  • Provide at least two parties/candidates for meaningful display.
  • For parliamentary/legislative results, use seats* and (optionally) seat_change*.
  • Colors: prefer official/consistent party colors. Use colorN; colourN is a fallback.
  • Avoid transcluding very large map SVGs without a defined map_size.

Common pitfalls

  • Script error about unknown function names often means a missing module/template. Ensure Module:InfoboxImage and {{Percentage bar}} exist locally.
  • If nested module = Template:Infobox legislative election … does not render, confirm that the nested template supports |embed=yes and does not output its own infobox wrapper when embedded.
  • If tracking for unknown parameters is enabled and you see warnings, remove or correct the named parameter.

TemplateData

Election infobox supporting presidential and legislative contests, with up to nine candidates/parties and optional maps/progress bars.

Template parameters

ParameterDescriptionTypeStatus
Election nameelection_name

Display title shown at top.

Stringoptional
Countrycountry

no description

Stringoptional
Typetype

presidential, parliamentary, legislative, or by-election

Suggested values
presidential parliamentary legislative by-election
Stringoptional
Election dateelection_date

no description

Stringoptional
Vote typevote_type

no description

Default
Popular
Stringoptional
Turnoutturnout

no description

Stringoptional
Registered votersregistered

no description

Stringoptional
Previous electionprevious_election

no description

Page nameoptional
Previous yearprevious_year

no description

Stringoptional
Next electionnext_election

no description

Page nameoptional
Next yearnext_year

no description

Stringoptional
Image 1image1

no description

Contentoptional
Nominee 1nominee1

no description

Useroptional
Running mate 1running_mate1

no description

Useroptional
Party 1party1

no description

Stringoptional
Popular vote 1popular_vote1

no description

Stringoptional
Percentage 1percentage1

no description

Stringoptional
Image 2image2

no description

Contentoptional
Nominee 2nominee2

no description

Useroptional
Running mate 2running_mate2

no description

Useroptional
Party 2party2

no description

Stringoptional
Popular vote 2popular_vote2

no description

Stringoptional
Percentage 2percentage2

no description

Stringoptional
Image 3image3

no description

Contentoptional
Nominee 3nominee3

no description

Useroptional
Party 3party3

no description

Stringoptional
Map imagemap_image

no description

Contentoptional
Map captionmap_caption

no description

Stringoptional
Map sizemap_size

no description

Default
300px
Stringoptional
Embedded modulemodule

Nested infobox template (e.g., Infobox legislative election) with |embed=yes.

Contentoptional

See also

Categories

Template:Template documentation