Open main menu

Changes

Template:Collapsible list/doc

8,167 bytes added, 12:00, 7 July 2020
m
change source to syntaxhighlight
{{Documentation subpage}}
{{Template shortcuts|clist}}
{{lua|Module:Collapsible list}}

This template produces a collapsible list. It is possible to set [[CSS]] styles for the "frame" (the {{tag|div}} tags surrounding the list), for the list title, and for the list items. The template supports an unlimited number of list items.

This template is typically used in [[WP:Infobox|infoboxes]] and [[WP:NAVBOX|navboxes]]; it should not normally be used in regular article content, per [[MOS:DONTHIDE]].

Regarding using this template in infoboxes, MOS:DONTHIDE acknowledges that "a few infoboxes also use pre-collapsed sections for infrequently accessed details. If [such] information ... seems extraneous or trivial enough to inspire pre-collapsing it, consider raising a discussion on the article (or template) talk page about whether it should be [[Wikipedia:What Wikipedia is not#Wikipedia is not an indiscriminate collection of information|included at all]]."

{{Collapse Templates}}

== Syntax ==
<syntaxhighlight lang="html" style="font-size:95%;overflow:auto;">
{{Collapsible list
| expand =
| framestyle =
| titlestyle =
| title =
| liststyle =
| hlist =
| bullets =
| 1 = <!--(First item in list; the "1 =" is usually not required)-->
| 2 = <!--(Second item in list; ditto)-->
| 3 = <!--(Third item in list; etc.)-->
| <!-- etc -->
}}
</syntaxhighlight>

== Parameters ==
{{Aligned table
|style=line-height:1.35em;
|col1style=padding-right:1.5em; |col2style=vertical-align:middle;
| ''expand'' | Any text in this parameter (including "no") sets the list's default state to expanded rather than collapsed. Omit the parameter or leave it blank to set the default state to collapsed.
| ''framestyle'' | Custom CSS styling applied the template overall (title and list).
| ''titlestyle'' | Custom CSS styling applied to the title.
| ''title'' | The list's title (always on view beside the list's [show/hide] link).
| ''liststyle'' | Custom CSS styling applied to the list (specifically, to the {{tag|ul}} tags delimiting the list).
| ''hlist'' | Include as {{para|hlist|on}}, {{para|hlist|true}}, etc to produce a horizontal rather than vertical list.
| ''bullets'' | Include as {{para|bullets|on}}, {{para|bullets|true}}, etc to place a [[Bullet (typography)|bullet point]] before each list item.
| Unnamed parameters<br>(first, second, third...) | The list items (in the order in which they will appear). If none are supplied, the template outputs nothing.
}}

== Examples ==
<syntaxhighlight lang="Moin" style="font-size:95%;overflow:auto;">
{{Collapsible list
| title = [[European Free Trade Association]] members
| [[Iceland]]
| [[Liechtenstein]]
| [[Norway]]
| [[Switzerland]]
}}
</syntaxhighlight>
{{collapsible list |title=[[European Free Trade Association]] members |[[Iceland]] |[[Liechtenstein]] |[[Norway]] |[[Switzerland]]}}

=== Example of a list without borders because it is within an infobox ===
In these examples, the fields leader_name2 and leader_name3 have been changed to use collapsible list.
{{Infobox settlement
|official_name = City of Hamilton
|motto = Together Aspire – Together Achieve
|image_skyline = HamiltonOntarioSkylineC.JPG
|imagesize = 250px
|image_caption = <!--
|image_map = Map of Ontario HAMILTON.svg
|mapsize = 200px
|map_caption = Location in the province of Ontario, Canada-->
|subdivision_type = Country
|subdivision_name = Canada
|subdivision_type1 = [[Provinces and territories of Canada|Province]]
|subdivision_name1 = [[Ontario]]
|leader_title = [[Mayor]]
|leader_name = [[Fred Eisenberger]]
|leader_title1 = [[City Council]]
|leader_name1 = [[Hamilton, Ontario, City Council]]
|leader_title2 = [[Member of Parliament#Canada|MPs]]
|leader_name2 =
{{Collapsible list
|framestyle=border:none; padding:0; <!--Hides borders and improves row spacing-->
|title=List of MPs
|1=[[Dean Allison]] |2=[[Chris Charlton]] |3=[[David Christopherson]] |4=[[Wayne Marston]] |5=[[David Sweet]]
}}
|leader_title3 = [[Member of Provincial Parliament (Ontario)|MPPs]]
|leader_name3 =
{{Collapsible list
|framestyle=border:none; padding:0; <!--as above-->
|title=List of MPPs
|1=[[Marie Bountrogianni]] |2=[[Andrea Horwath]] |3=[[Judy Marsales]] |4=[[Ted McMeekin]] |5=[[Jennifer Mossop]]
}}
|established_title = [[Municipal corporation|Incorporated]]
|established_date = June 9, 1846
|short_description =
}}
<syntaxhighlight lang="html" style="font-size:95%; overflow:auto;">
{{Infobox settlement
|official_name = City of Hamilton
...truncated...
|leader_title = [[Mayor]]
|leader_name = [[Fred Eisenberger]]
|leader_title1 = [[City Council]]
|leader_name1 = [[Hamilton City Council]]
|leader_title2 = [[Member of Parliament (Canada)|MPs]]
|leader_name2 =
{{Collapsible list
|framestyle=border:none; padding:0; <!--Hides borders and improves row spacing-->
|title=List of MPs
|1=[[Dean Allison]] |2=[[Chris Charlton]] |3=[[David Christopherson]] |4=[[Wayne Marston]] |5=[[David Sweet]]
}}
|leader_title3 = [[Member of Provincial Parliament (Ontario)|MPPs]]
|leader_name3 =
{{Collapsible list
|framestyle=border:none; padding:0; <!--as above-->
|title=List of MPPs
|1=[[Marie Bountrogianni]] |2=[[Andrea Horwath]] |3=[[Judy Marsales]] |4=[[Ted McMeekin]] |5=[[Jennifer Mossop]]
}}
|established_title = [[Municipal corporation|Incorporated]]
|established_date = June 9, 1846
(...etc...)
}}
</syntaxhighlight>

== TemplateData ==
{{TemplateDataHeader}}
<templatedata>
{
"params": {
"1": {
"label": "First list item",
"description": "A single list item",
"type": "content",
"suggested": true
},
"2": {
"label": "Second list item",
"description": "A single list item",
"type": "content",
"suggested": true
},
"3": {
"label": "Third list item",
"description": "A single list item",
"type": "content",
"suggested": true
},
"4": {
"label": "Fourth list item",
"description": "A single list item",
"type": "content"
},
"5": {
"type": "content"
},
"6": {
"type": "content"
},
"7": {
"type": "content"
},
"8": {
"type": "content"
},
"9": {
"type": "content"
},
"10": {
"type": "content"
},
"expand": {
"label": "Expand list",
"description": "Expand the list instead of collapsing it",
"example": "true",
"type": "string",
"autovalue": "true"
},
"framestyle": {
"aliases": [
"frame_style"
],
"label": "Frame style",
"description": "Custom CSS styling applied the template overall (title and list).",
"example": "border: 1px;",
"type": "string"
},
"titlestyle": {
"aliases": [
"title_style"
],
"label": "Title style",
"description": "CSS styling applied to the title",
"example": "color:brown;",
"type": "string"
},
"title": {
"label": "Title",
"description": "The list's title (Always in view beside the list's [show/hide] link).",
"type": "string",
"suggested": true
},
"liststyle": {
"aliases": [
"list_style"
],
"label": "List style",
"description": "CSS styling applied solely to the list itself",
"example": "list-style-type: square;",
"type": "string"
},
"hlist": {
"label": "Horizontal list",
"description": "Use value 'on' or 'true' to produce a horizontal rather than vertical list",
"example": "true",
"type": "string",
"autovalue": "true"
},
"bullets": {
"label": "Bullets",
"description": "Set as 'on' or 'true' to place a bullet point before each list item",
"example": "true",
"type": "string",
"autovalue": "true"
}
},
"description": "Produces an HTML list that can be collapsed",
"paramOrder": [
"title",
"hlist",
"bullets",
"expand",
"1",
"framestyle",
"titlestyle",
"liststyle",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10"
],
"format": "block"
}
</templatedata>

<includeonly>{{Sandbox other||
[[Category:Collapse templates]]
[[Category:List formatting and function templates]]

}}</includeonly>
Anonymous user