Template:TOC: Difference between revisions

From Handhelds Wiki
Jump to navigationJump to search
m 1 revision imported
No edit summary
Line 1: Line 1:
{{#if:{{{limit|}}}|<templatestyles src="TOC/limit-styles.css"/>}}<div style="{{#if:{{{clear|}}}{{{align|}}}| clear: {{{clear|both}}}; }} margin-bottom: .5em; float: {{{align|none}}}; {{#ifeq: {{lc:{{{align|}}}}} | right | margin-left:2em; | {{#ifeq: {{lc:{{{align|}}}}} | left | margin-right:2em; | <!-- align=none --> }} }} width: {{{width|auto}}};" {{#if:{{{limit|}}}|class="toclimit-{{{limit}}}"}}>__TOC__</div><noinclude>
<includeonly>
{{doc}}
<div class="custom-toc" style="margin: 1em 0;">
[[Category:Utility templates|{{PAGENAME}}]]
  __TOC__
</div>
 
<style>
/* Default max level is 3 unless specified */
.custom-toc .toclevel-3 ~ .toclevel-4,
.custom-toc .toclevel-3 ~ .toclevel-5,
.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|
    .custom-toc .toclevel-3 ~ .toclevel-4,
    .custom-toc .toclevel-3 ~ .toclevel-5,
    .custom-toc .toclevel-3 ~ .toclevel-6 { display: none; }
  }}
  {{#ifeq:{{{limit}}}|4|
    .custom-toc .toclevel-4 ~ .toclevel-5,
    .custom-toc .toclevel-4 ~ .toclevel-6 { display: none; }
  }}
  </style>
}}
</includeonly>
<noinclude>
This template inserts a custom-styled TOC and allows you to limit depth.
 
Usage: `{{TOC|limit=3}}`
Supported limits: 2, 3, 4
</noinclude>
</noinclude>

Revision as of 17:59, 10 May 2025


This template inserts a custom-styled TOC and allows you to limit depth.

Usage: `

<style> /* Default max level is 3 unless specified */ .custom-toc .toclevel-3 ~ .toclevel-4, .custom-toc .toclevel-3 ~ .toclevel-5, .custom-toc .toclevel-3 ~ .toclevel-6 {

 display: none;

} </style>

<style>

 .custom-toc .toclevel-3 ~ .toclevel-4,
   .custom-toc .toclevel-3 ~ .toclevel-5,
   .custom-toc .toclevel-3 ~ .toclevel-6 { display: none; }
 
 </style>

` Supported limits: 2, 3, 4