Template:Infobox election/doc: Difference between revisions

From Chalo Chatu, Zambia online encyclopedia
Jump to navigationJump to search
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): <..."
 
No edit summary
 
Line 1: Line 1:
{{Documentation subpage}}
{{Documentation subpage}}
{{High-risk|reason=Heavily used across election articles; changes affect many pages.}}


= Template:Infobox election =
== Purpose ==
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.
This template is used to create a consistent and informative infobox for articles about elections in Zambia and beyond. It presents key facts such as the election date, type, country, turnout, main candidates, votes, percentages, and election maps.


== Basic usage ==
== Usage ==
Minimal example (presidential):
Place this template at the top of any election article. Only include parameters that are known. Empty fields will be automatically hidden.
 
== Example ==
<pre>
<pre>
{{Infobox election
{{Infobox election
| election_name = 2021 Zambian general election
| election_name = 2026 Zambian General Election
| country      = Zambia
| type = Presidential
| type         = presidential
| election_date = 12 August 2026
| election_date = {{Start date|2021|8|12|df=yes}}
| country = Zambia
| vote_type    = Popular
| turnout = 65.3%
| turnout       = 70.61%
| registered = 7,300,000
 
| previous_link = 2021 Zambian general election
| image1        = [[File:HH2022.png|130x130px]]
| previous_year = 2021
| nominee1     = [[Hakainde Hichilema]]
| next_link = 2031 Zambian general election
| running_mate1 = [[Mutale Nalumango]]
| next_year = 2031
| party1       = United Party for National Development
| nominee1 = Hakainde Hichilema
| popular_vote1 = 2,852,348
| party1 = UPND
| percentage1   = 59.02%
| popular_vote1 = 3,000,000
 
| percentage1 = 51.2
| image2        = [[File:Edgar Lungu, 26 july 2018 (cropped).jpg|130x130px]]
| nominee2 = Edgar Lungu
| nominee2     = [[Edgar Lungu]]
| party2 = PF
| running_mate2 = [[Nkandu Luo]]
| popular_vote2 = 2,600,000
| party2       = Patriotic Front (Zambia)
| percentage2 = 44.3
| popular_vote2 = 1,870,780
| map_image = Zambia 2026 election map.png
| percentage2   = 38.71%
}}
}}
</pre>
</pre>


Nested (module) infoboxes (e.g., add a legislative block inside the main infobox) are supported via:
== Parameters ==
<pre>
=== General Information ===
| module = {{Infobox legislative election
; election_name : Title of the election.
  | embed              = yes
; type : Type of election (e.g., Presidential, Parliamentary, By-election).
  | election_name      = National Assembly election
; election_date : Date when the election took place.
  | seats_for_election = 156 of the 167 seats in the [[National Assembly of Zambia|National Assembly]]
; country : Name of the country (default: Zambia).
  | majority_seats    = 85
; turnout : Voter turnout percentage.
  | leader1            = [[Hakainde Hichilema]]
; registered : Number of registered voters.
  | party1            = United Party for National Development
; previous_link / previous_year : Page link and year of the previous election.
  | seats1            = 82
; next_link / next_year : Page link and year of the next election.
  | leader2            = [[Edgar Lungu]]
  | party2            = Patriotic Front (Zambia)
  | seats2            = 59
}}
</pre>
 
== 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 {{Start date}}.
; 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 {{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:…|150x150px]]).
; 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:
<pre>
.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; }
</pre>
Add to '''MediaWiki:Common.css'''.
 
== Dependencies ==
Required (or adjust template to remove calls):
* {{Tl|Infobox}} (or your local base infobox wrapper)
* {{Tl|Percentage bar}} for progress bars
* {{Tl|Succession links}} for prev/next/year band (optional but recommended)
* [[Module:InfoboxImage]] (used via {{#invoke:InfoboxImage}})
* If you use flags: {{Tl|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 '''<noinclude>''')
 
== 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 {{Tl|Percentage bar}} exist locally.
* If nested '''module = {{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 ==
<templatedata>
{
  "description": "Election infobox supporting presidential and legislative contests, with up to nine candidates/parties and optional maps/progress bars.",
  "params": {
    "election_name": {"label": "Election name","description": "Display title shown at top.","type": "string"},
    "country": {"label": "Country","type": "string"},
    "type": {"label": "Type","description": "presidential, parliamentary, legislative, or by-election","type": "string","suggestedvalues": ["presidential","parliamentary","legislative","by-election"]},
    "election_date": {"label": "Election date","type": "string"},
    "vote_type": {"label": "Vote type","type": "string","default": "Popular"},
    "turnout": {"label": "Turnout","type": "string"},
    "registered": {"label": "Registered voters","type": "string"},
    "previous_election": {"label": "Previous election","type": "wiki-page-name"},
    "previous_year": {"label": "Previous year","type": "string"},
    "next_election": {"label": "Next election","type": "wiki-page-name"},
    "next_year": {"label": "Next year","type": "string"},
 
    "image1": {"label": "Image 1","type": "content"},
    "nominee1": {"label": "Nominee 1","type": "wiki-user-name"},
    "running_mate1": {"label": "Running mate 1","type": "wiki-user-name"},
    "party1": {"label": "Party 1","type": "string"},
    "popular_vote1": {"label": "Popular vote 1","type": "string"},
    "percentage1": {"label": "Percentage 1","type": "string"},
 
    "image2": {"label": "Image 2","type": "content"},
    "nominee2": {"label": "Nominee 2","type": "wiki-user-name"},
    "running_mate2": {"label": "Running mate 2","type": "wiki-user-name"},
    "party2": {"label": "Party 2","type": "string"},
    "popular_vote2": {"label": "Popular vote 2","type": "string"},
    "percentage2": {"label": "Percentage 2","type": "string"},
 
    "image3": {"label": "Image 3","type": "content"},
    "nominee3": {"label": "Nominee 3","type": "wiki-user-name"},
    "party3": {"label": "Party 3","type": "string"},


    "map_image": {"label": "Map image","type": "content"},
=== Candidates ===
    "map_caption": {"label": "Map caption","type": "string"},
Supports up to three candidates.
    "map_size": {"label": "Map size","type": "string","default": "300px"},


    "module": {"label": "Embedded module","description": "Nested infobox template (e.g., Infobox legislative election) with |embed=yes.","type": "content"}
; nominee1 / nominee2 / nominee3 : Name of the candidate.
  }
; party1 / party2 / party3 : Political party of the nominee.
}
; popular_vote1 / popular_vote2 / popular_vote3 : Total number of votes received.
</templatedata>
; percentage1 / percentage2 / percentage3 : Percentage of votes received.


== See also ==
=== Map ===
* {{Tl|Infobox legislative election}}
; map_image : Name of the map image file (without "File:").
* {{Tl|Election results}}
; map_caption : (Optional) Description below the map.
* [[Help:Infobox]]


== Categories ==
== Notes ==
{{Template documentation}}
* Only non-empty fields will appear in the o*

Latest revision as of 10:51, 19 September 2025

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.

Purpose

This template is used to create a consistent and informative infobox for articles about elections in Zambia and beyond. It presents key facts such as the election date, type, country, turnout, main candidates, votes, percentages, and election maps.

Usage

Place this template at the top of any election article. Only include parameters that are known. Empty fields will be automatically hidden.

Example

{{Infobox election
| election_name = 2026 Zambian General Election
| type = Presidential
| election_date = 12 August 2026
| country = Zambia
| turnout = 65.3%
| registered = 7,300,000
| previous_link = 2021 Zambian general election
| previous_year = 2021
| next_link = 2031 Zambian general election
| next_year = 2031
| nominee1 = Hakainde Hichilema
| party1 = UPND
| popular_vote1 = 3,000,000
| percentage1 = 51.2
| nominee2 = Edgar Lungu
| party2 = PF
| popular_vote2 = 2,600,000
| percentage2 = 44.3
| map_image = Zambia 2026 election map.png
}}

Parameters

General Information

election_name
Title of the election.
type
Type of election (e.g., Presidential, Parliamentary, By-election).
election_date
Date when the election took place.
country
Name of the country (default: Zambia).
turnout
Voter turnout percentage.
registered
Number of registered voters.
previous_link / previous_year
Page link and year of the previous election.
next_link / next_year
Page link and year of the next election.

Candidates

Supports up to three candidates.

nominee1 / nominee2 / nominee3
Name of the candidate.
party1 / party2 / party3
Political party of the nominee.
popular_vote1 / popular_vote2 / popular_vote3
Total number of votes received.
percentage1 / percentage2 / percentage3
Percentage of votes received.

Map

map_image
Name of the map image file (without "File:").
map_caption
(Optional) Description below the map.

Notes

  • Only non-empty fields will appear in the o*