Difference between revisions of "Template:TOC"

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "<tt>([^ =]+)<\/tt>" to "{{hl|$1}}")
(Fix default case, Add example)
 
Line 20: Line 20:
 
}}
 
}}
 
|
 
|
def __TOC__
+
__TOC__
 
}}</div></includeonly><noinclude>
 
}}</div></includeonly><noinclude>
 
{{Feature | important | Only '''one''' TOC (Table of Contents) is possible per page, with the exception of ''abc'' and ''subtoc''.}}
 
{{Feature | important | Only '''one''' TOC (Table of Contents) is possible per page, with the exception of ''abc'' and ''subtoc''.}}
Line 48: Line 48:
 
! Code
 
! Code
 
! Result
 
! Result
 +
|-
 +
| <pre>{{TOC}}</pre>
 +
| style="padding-left: 2.5em" |
 +
{{TOC}}
 
|-
 
|-
 
| <pre>{{TOC|abc}}</pre>
 
| <pre>{{TOC|abc}}</pre>

Latest revision as of 23:04, 15 September 2022

Only one TOC (Table of Contents) is possible per page, with the exception of abc and subtoc.

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
Examples
Code Result
{{TOC}}
{{TOC|abc}}
{{TOC|subtoc
|content=
* 1. {{HashLink|#Title 1}}
* 2. {{HashLink|#Title 2}}
* 3. {{HashLink|#Title 3}}
}}
Contents
{{TOC|subtoc
|title= The sub-TOC title
|content=
* 1. {{HashLink|#Title 1}}
* 2. {{HashLink|#Title 2}}
* 3. {{HashLink|#Title 3}}
}}
The sub-TOC title