Template:Infobox election/doc
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.,
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):
- {{Infobox}} (or your local base infobox wrapper)
- {{Percentage bar}} for progress bars
- {{Succession links}} for prev/next/year band (optional but recommended)
- Module:InfoboxImage (used via Script error: You must specify a function to call.)
- If you use flags: {{flagdeco}} and related flag templates
Nice to have (site hygiene):
- Module:Check for unknown parameters (only if you enable tracking at the bottom of the template; recommended to keep inside ')
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.
Parameter | Description | Type | Status | |
---|---|---|---|---|
Election name | election_name | Display title shown at top. | String | optional |
Country | country | no description | String | optional |
Type | type | presidential, parliamentary, legislative, or by-election
| String | optional |
Election date | election_date | no description | String | optional |
Vote type | vote_type | no description
| String | optional |
Turnout | turnout | no description | String | optional |
Registered voters | registered | no description | String | optional |
Previous election | previous_election | no description | Page name | optional |
Previous year | previous_year | no description | String | optional |
Next election | next_election | no description | Page name | optional |
Next year | next_year | no description | String | optional |
Image 1 | image1 | no description | Content | optional |
Nominee 1 | nominee1 | no description | User | optional |
Running mate 1 | running_mate1 | no description | User | optional |
Party 1 | party1 | no description | String | optional |
Popular vote 1 | popular_vote1 | no description | String | optional |
Percentage 1 | percentage1 | no description | String | optional |
Image 2 | image2 | no description | Content | optional |
Nominee 2 | nominee2 | no description | User | optional |
Running mate 2 | running_mate2 | no description | User | optional |
Party 2 | party2 | no description | String | optional |
Popular vote 2 | popular_vote2 | no description | String | optional |
Percentage 2 | percentage2 | no description | String | optional |
Image 3 | image3 | no description | Content | optional |
Nominee 3 | nominee3 | no description | User | optional |
Party 3 | party3 | no description | String | optional |
Map image | map_image | no description | Content | optional |
Map caption | map_caption | no description | String | optional |
Map size | map_size | no description
| String | optional |
Embedded module | module | Nested infobox template (e.g., Infobox legislative election) with |embed=yes. | Content | optional |