TOC – Template
| m (Fixed documentation) | Lou Montana (talk | contribs)   (Add subTOC, made 'mode' case-insensitive) | ||
| Line 1: | Line 1: | ||
| <includeonly><div class="{{#if:{{{3|}}}|toclimit-{{{3|}}}}} {{#if:{{{4|}}}|toc-nonum}}" {{#if:{{{2|}}}|style="font-size: {{{2}}}em"}}>{{#switch:{{{1|}}} | <includeonly><div class="{{#if:{{{3|}}}|toclimit-{{{3|}}}}} {{#if:{{{4|}}}|toc-nonum}}" {{#if:{{{2|}}}|style="font-size: {{{2}}}em"}}>{{#switch:{{lc:{{{1|}}}}} | ||
| |abc= | |abc= | ||
| 	__NOTOC__ | 	__NOTOC__ | ||
| Line 9: | Line 9: | ||
| |side= | |side= | ||
| 	<div class="toc-side">__TOC__</div> | 	<div class="toc-side">__TOC__</div> | ||
| |subtoc= | |||
| 	{{#if:{{{content|}}} | |||
| 	| | |||
| 		<div class="toc" style="font-size: .9em"> | |||
| 		<div class="toctitle"><h2>{{{title|Contents}}}</h2></div> | |||
| {{{content}}} | |||
| 		</div> | |||
| 	| | |||
| 		__TOC__ | |||
| 	}} | |||
| | | | | ||
| 	__TOC__ | 	def __TOC__ | ||
| }}</div></includeonly><noinclude> | }}</div></includeonly><noinclude> | ||
| {{Feature | important | Only '''one''' TOC (Table of Contents) is possible per page, with the exception of the ''abc'' one.}} | {{Feature | important | Only '''one''' TOC (Table of Contents) is possible per page, with the exception of the ''abc'' one.}} | ||
| == Usage == | == Usage == | ||
| {{<nowiki/>TOC|'''''mode'''''|'''''size'''''|'''''limit'''''|'''''nonum'''''}} | {{<nowiki/>TOC|'''''mode'''''|'''''size'''''|'''''limit'''''|'''''nonum'''''|'''''title='''''|'''''content='''''}} | ||
| * mode: (Optional, default: "normal"; case- | * mode: (Optional, default: "normal"; case-insensitive) one of: | ||
| ** abc - a horizontal A..Z TOC (more of an ''index'') | ** abc - a horizontal A..Z TOC (more of an ''index'') | ||
| ** horizontal - a horizontal TOC, where full titles are kept | ** horizontal - a horizontal TOC, where full titles are kept | ||
| Line 22: | Line 32: | ||
| ** none - no TOC on the page (similar to <tt><nowiki>__NOTOC__</nowiki></tt>) | ** none - no TOC on the page (similar to <tt><nowiki>__NOTOC__</nowiki></tt>) | ||
| ** side - sets the TOC to the right | ** side - sets the TOC to the right | ||
| ** subtoc - creates a TOC-like box. Additional parameters: | |||
| *** title: (Optional, default empty) subTOC title | |||
| *** content: subTOC content, usually a list of [[Template:HashLink|HashLink]] internal links in format:<syntaxhighlight lang="html"> | |||
| * 1. {{HashLink|#Title 1}} | |||
| * 2. {{HashLink|#Title 2}} | |||
| * 3. {{HashLink|#Title 3}} | |||
| </syntaxhighlight> | |||
| * size: (Optional, default 1) size in em (e.g <tt>.9</tt> for 90%) | * size: (Optional, default 1) size in em (e.g <tt>.9</tt> for 90%) | ||
| * limit: (Optional, default empty) sub-level limit (e.g <tt>2</tt>) | * limit: (Optional, default empty) sub-level limit (e.g <tt>2</tt>) | ||
| * nonum: (Optional, default empty) <tt>y</tt> to hide numbers | * nonum: (Optional, default empty) <tt>y</tt> to hide numbers | ||
| {| style="width: 100%" | |||
| |+ Examples | |||
| |- style="background-color: #EEE" | |||
| ! Code | |||
| ! Result | |||
| |- | |||
| | <pre>{{TOC|abc}}</pre> | |||
| | {{TOC|abc}} | |||
| |- | |||
| | <pre>{{TOC|subtoc | |||
| |content= | |||
| * 1. {{HashLink|#Title 1}} | |||
| * 2. {{HashLink|#Title 2}} | |||
| * 3. {{HashLink|#Title 3}} | |||
| }}</pre> | |||
| | style="padding-left: 2.5em" | | |||
| {{TOC|subtoc | |||
| |content= | |||
| * 1. {{HashLink|#Title 1}} | |||
| * 2. {{HashLink|#Title 2}} | |||
| * 3. {{HashLink|#Title 3}} | |||
| }} | |||
| |- | |||
| | <pre>{{TOC|subtoc | |||
| |title= The sub-TOC title | |||
| |content= | |||
| * 1. {{HashLink|#Title 1}} | |||
| * 2. {{HashLink|#Title 2}} | |||
| * 3. {{HashLink|#Title 3}} | |||
| }}</pre> | |||
| | style="padding-left: 2.5em" | | |||
| {{TOC|subtoc | |||
| |title= The sub-TOC title | |||
| |content= | |||
| * 1. {{HashLink|#Title 1}} | |||
| * 2. {{HashLink|#Title 2}} | |||
| * 3. {{HashLink|#Title 3}} | |||
| }} | |||
| |} | |||
| <!-- | <!-- | ||
| {| class="wikitable" style="width: 100%" | {| class="wikitable" style="width: 100%" | ||
Revision as of 01:30, 6 August 2021
Usage
{{TOC|mode|size|limit|nonum|title=|content=}}
- mode: (Optional, default: "normal"; case-insensitive) one of:
- abc - a horizontal A..Z TOC (more of an index)
- horizontal - a horizontal TOC, where full titles are kept
- normal - the normal TOC - can be placed at the wanted position with this
- none - no TOC on the page (similar to __NOTOC__)
- side - sets the TOC to the right
- subtoc - creates a TOC-like box. Additional parameters:
- title: (Optional, default empty) subTOC title
- content: subTOC content, usually a list of HashLink internal links in format:* 1. {{HashLink|#Title 1}} * 2. {{HashLink|#Title 2}} * 3. {{HashLink|#Title 3}}
 
 
- size: (Optional, default 1) size in em (e.g .9 for 90%)
- limit: (Optional, default empty) sub-level limit (e.g 2)
- nonum: (Optional, default empty) y to hide numbers
| Code | Result | 
|---|---|
| {{TOC|abc}} | |
| {{TOC|subtoc
|content=
* 1. {{HashLink|#Title 1}}
* 2. {{HashLink|#Title 2}}
* 3. {{HashLink|#Title 3}}
}} | |
| {{TOC|subtoc
|title= The sub-TOC title
|content=
* 1. {{HashLink|#Title 1}}
* 2. {{HashLink|#Title 2}}
* 3. {{HashLink|#Title 3}}
}} | 
