Template:TOC: Difference between revisions

From Handhelds Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
<includeonly>
<onlyinclude>
<div class="custom-toc" style="margin: 1em 0;">
<div class="custom-toc" style="margin: 1em 0;">
   __TOC__
   __TOC__
</div>
</div>


<style>
<templatestyles src="Template:TOC/styles.css" />
/* Default max level is 3 unless specified */
{{#if: {{{limit|}}} |
.custom-toc .toclevel-3 ~ .toclevel-4,
   {{#ifeq: {{{limit}}} | 2 |
.custom-toc .toclevel-3 ~ .toclevel-5,
     .custom-toc .toclevel-3, .custom-toc .toclevel-4, .custom-toc .toclevel-5, .custom-toc .toclevel-6 { display: none; }
.custom-toc .toclevel-3 ~ .toclevel-6 {
  display: none;
}
</style>
 
{{#if:{{{limit|}}}|
  <style>
   {{#ifeq:{{{limit}}}|2|
     .custom-toc .toclevel-2 ~ .toclevel-3,
    .custom-toc .toclevel-2 ~ .toclevel-4,
    .custom-toc .toclevel-2 ~ .toclevel-5,
    .custom-toc .toclevel-2 ~ .toclevel-6 { display: none; }
   }}
   }}
   {{#ifeq:{{{limit}}}|3|
   {{#ifeq: {{{limit}}} | 3 |
     .custom-toc .toclevel-3 ~ .toclevel-4,
     .custom-toc .toclevel-4, .custom-toc .toclevel-5, .custom-toc .toclevel-6 { display: none; }
    .custom-toc .toclevel-3 ~ .toclevel-5,
    .custom-toc .toclevel-3 ~ .toclevel-6 { display: none; }
   }}
   }}
   {{#ifeq:{{{limit}}}|4|
   {{#ifeq: {{{limit}}} | 4 |
     .custom-toc .toclevel-4 ~ .toclevel-5,
     .custom-toc .toclevel-5, .custom-toc .toclevel-6 { display: none; }
    .custom-toc .toclevel-4 ~ .toclevel-6 { display: none; }
   }}
   }}
  </style>
}}
}}
</includeonly>
</onlyinclude>
<noinclude>
This template creates a dynamic Table of Contents with a limit for the depth of the TOC.
Usage: `{{TOC|limit=3}}`
Supported limits: 2, 3, 4
</noinclude>

Revision as of 18:04, 10 May 2025


This template creates a dynamic Table of Contents with a limit for the depth of the TOC. Usage: `

.custom-toc .toclevel-4, .custom-toc .toclevel-5, .custom-toc .toclevel-6 { display: none; } ` Supported limits: 2, 3, 4