Difference between revisions of "Template:TOC"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (Created (based on Wikipedia's CompactTOC8))
 
m (Adding anchored headings to sample)
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{| id="toc" class="toc" summary="Contents" {{
 
{| id="toc" class="toc" summary="Contents" {{
 
<!-- center/right -->
 
<!-- center/right -->
#ifeq:{{{center|}}}|yes|align="center"|}}{{#ifeq:{{{right|}}}|yes|align="right"|}}
+
#ifeq:{{{align|}}}|center|align="center"|}}{{#ifeq:{{{align|}}}|right|align="right"|}}  
 
{{
 
{{
 
<!-- name/side -->
 
<!-- name/side -->
Line 12: Line 12:
 
#ifeq:{{{sym|}}}|yes|[[#!$@|!$@]]|}} {{
 
#ifeq:{{{sym|}}}|yes|[[#!$@|!$@]]|}} {{
 
<!-- numbers -->
 
<!-- numbers -->
#ifeq:{{{num|}}}|yes|[[#0–9|0–9]]|}} {{#ifeq:{{{symnum|}}}|yes|[[#!–9|!–9]]|
+
#ifeq:{{{num|}}}|yes|[[#0-9|0-9]]|}} {{#ifeq:{{{symnum|}}}|yes|[[#!-9|!-9]]|
 
<!-- letters -->
 
<!-- letters -->
 
}} {{{a|[[#A|A]]}}} {{{b|[[#B|B]]}}} {{{c|[[#C|C]]}}} {{{d|[[#D|D]]}}} {{{e|[[#E|E]]}}} {{{f|[[#F|F]]}}} {{{g|[[#G|G]]}}} {{{h|[[#H|H]]}}} {{{i|[[#I|I]]}}} {{{j|[[#J|J]]}}} {{{k|[[#K|K]]}}} {{{l|[[#L|L]]}}} {{{m|[[#M|M]]}}} {{{n|[[#N|N]]}}} {{{o|[[#O|O]]}}} {{{p|[[#P|P]]}}} {{{q|[[#Q|Q]]}}} {{{r|[[#R|R]]}}} {{{s|[[#S|S]]}}} {{{t|[[#T|T]]}}} {{{u|[[#U|U]]}}} {{{v|[[#V|V]]}}} {{{w|[[#W|W]]}}} {{{x|[[#X|X]]}}} {{{y|[[#Y|Y]]}}} {{{z|[[#Z|Z]]}}} {{#ifeq:{{{nobreak|{{#ifeq:{{{1}}}|short1|yes|}}}}}|yes|&nbsp;|<br />}}{{
 
}} {{{a|[[#A|A]]}}} {{{b|[[#B|B]]}}} {{{c|[[#C|C]]}}} {{{d|[[#D|D]]}}} {{{e|[[#E|E]]}}} {{{f|[[#F|F]]}}} {{{g|[[#G|G]]}}} {{{h|[[#H|H]]}}} {{{i|[[#I|I]]}}} {{{j|[[#J|J]]}}} {{{k|[[#K|K]]}}} {{{l|[[#L|L]]}}} {{{m|[[#M|M]]}}} {{{n|[[#N|N]]}}} {{{o|[[#O|O]]}}} {{{p|[[#P|P]]}}} {{{q|[[#Q|Q]]}}} {{{r|[[#R|R]]}}} {{{s|[[#S|S]]}}} {{{t|[[#T|T]]}}} {{{u|[[#U|U]]}}} {{{v|[[#V|V]]}}} {{{w|[[#W|W]]}}} {{{x|[[#X|X]]}}} {{{y|[[#Y|Y]]}}} {{{z|[[#Z|Z]]}}} {{#ifeq:{{{nobreak|{{#ifeq:{{{1}}}|short1|yes|}}}}}|yes|&nbsp;|<br />}}{{
<!-- see also-->
+
<!-- see also -->
 
#ifeq:{{{seealso|}}}|yes|{{{sep|&nbsp;}}} [[#See also{{!}}See also]]&nbsp;|}}
 
#ifeq:{{{seealso|}}}|yes|{{{sep|&nbsp;}}} [[#See also{{!}}See also]]&nbsp;|}}
 
</div>
 
</div>
 
|}__NOTOC__<noinclude>
 
|}__NOTOC__<noinclude>
== Description ==
+
The [[Template:TOC|TOC]] template creates a replacement '''Table of Contents''' for alphabetical lists:
This is a replacement '''Table of Contents''' for alphabetical lists:
+
 
:* The "Contents" or a custom heading can go on top (default) or the side (side=yes).
 
:* The "Contents" or a custom heading can go on top (default) or the side (side=yes).
:* [[#Letters|Letters]] can be omitted and/or ranges set instead of 26 individual letters: A B C-F G H-K L ...
+
:* letters can be omitted and/or merged into ranges: A B C-F G H-K L ...
:* Other options include: center=yes, num=yes, top=yes, seealso=yes, etc.
+
:* Other options include: align=center, num=yes, top=yes, seealso=yes, etc.
  
 
== Usage ==
 
== Usage ==
=== Typical ===
 
 
<code><nowiki>{{</nowiki>'''TOC'''<nowiki>}}</nowiki></code>
 
 
<code><nowiki>{{</nowiki>'''TOC'''|symnum=yes<nowiki>}}</nowiki></code>
 
 
=== Complete ===
 
  
 
<pre>
 
<pre>
Line 38: Line 30:
 
|name    =
 
|name    =
 
|side    = yes
 
|side    = yes
|center  = yes
 
|right  =
 
 
|align  = center
 
|align  = center
 
|nobreak = yes
 
|nobreak = yes
Line 50: Line 40:
 
:
 
:
 
|z      =
 
|z      =
}}</pre>
+
}}
 
+
<!-- === <span id="A">A</span> ===
 +
-->
 +
<!-- === <span id="B">B</span> ===
 +
-->
 +
<!-- === <span id="C">C</span> ===
 +
-->
 +
<!-- === <span id="D">D</span> ===
 +
-->
 +
<!-- === <span id="E">E</span> ===
 +
-->
 +
<!-- === <span id="F">F</span> ===
 +
-->
 +
<!-- === <span id="G">G</span> ===
 +
-->
 +
<!-- === <span id="H">H</span> ===
 +
-->
 +
<!-- === <span id="I">I</span> ===
 +
-->
 +
<!-- === <span id="J">J</span> ===
 +
-->
 +
<!-- === <span id="K">K</span> ===
 +
-->
 +
<!-- === <span id="L">L</span> ===
 +
-->
 +
<!-- === <span id="K">K</span> ===
 +
-->
 +
<!-- === <span id="K">K</span> ===
 +
-->
 +
<!-- === <span id="M">M</span> ===
 +
-->
 +
<!-- === <span id="N">N</span> ===
 +
-->
 +
<!-- === <span id="O">O</span> ===
 +
-->
 +
<!-- === <span id="P">P</span> ===
 +
-->
 +
<!-- === <span id="Q">Q</span> ===
 +
-->
 +
<!-- === <span id="R">R</span> ===
 +
-->
 +
<!-- === <span id="S">S</span> ===
 +
-->
 +
<!-- === <span id="T">T</span> ===
 +
-->
 +
<!-- === <span id="U">U</span> ===
 +
-->
 +
<!-- === <span id="V">V</span> ===
 +
-->
 +
<!-- === <span id="W">W</span> ===
 +
-->
 +
<!-- === <span id="X">X</span> ===
 +
-->
 +
<!-- === <span id="Y">Y</span> ===
 +
-->
 +
<!-- === <span id="Z">Z</span> ===
 +
--></pre>
 
=== Parameters ===
 
=== Parameters ===
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
! Parameter !! Description
 
! Parameter !! Description
 +
|-
 
| <code>name</code>  
 
| <code>name</code>  
 
| replaces the "Contents" heading with an alternative name, or hide it completely by entering <code>name=no</code>
 
| replaces the "Contents" heading with an alternative name, or hide it completely by entering <code>name=no</code>
Line 62: Line 109:
 
|-
 
|-
 
| <code>align</code>  
 
| <code>align</code>  
| centres to TOC in the horizontal middle of the page, instead of floated left
+
| <code>align=center</code> aligns the TOC horizontal to the middle of the page; <code>align=right</code> aligns the TOC horizontally to the right of the page (may require <code><nowiki><br style="clear:right;"/></nowiki></code>   after it, depending on page layout)
|-
+
| <code>right</code>  
+
| aligns the TOC horizontally to the right of the page (may require <code><nowiki><br style="clear:right;" /></nowiki></code> after it, depending on page layout), instead of floated left (this  parameter is mutually exclusive with the "center" option above, and should be used sparingly and with good reason)
+
 
|-
 
|-
 
| <code>nobreak</code>  
 
| <code>nobreak</code>  
Line 71: Line 115:
 
|-
 
|-
 
| <code>top</code>   
 
| <code>top</code>   
| enables the "Top" link; this is only useful if this copy of the TOC is a secondary TOC not at the top of the page, e.g. in the  middle of a long glossary
+
| enables the "Top" link; this is only useful if this copy of the TOC is a secondary TOC not at the top of the page, e.g. in the  middle of a long glossary
 
|-
 
|-
 
| <code>sym</code>  
 
| <code>sym</code>  
 
| enables the "!$@" link for symbolic entries section
 
| enables the "!$@" link for symbolic entries section
|-
 
 
|-
 
|-
 
| <code>num</code>  
 
| <code>num</code>  
| enables the "0–9" link for numeric entries section (create a heading of <code><nowiki>==0&amp;ndash;9==</nowiki></code> for the link to work)
+
| enables the "0-9" link for numeric entries section (create a heading of <code><nowiki>==0&amp;ndash;9==</nowiki></code> for the link to work)
 
|-
 
|-
 
| <code>symnum</code>  
 
| <code>symnum</code>  
| enables the "!–9" link for combined symbolic and numeric entries section (create a heading of <code><nowiki>==!&amp;ndash;9==</nowiki></code> for the link to work)
+
| enables the "!-9" link for combined symbolic and numeric entries section (create a heading of <code><nowiki>==!&amp;ndash;9==</nowiki></code> for the link to work)
 +
|-
 +
| <code>sep</code>
 +
| sets the separator between the word-headers (but not the letters), for example <code>&amp;middot;</code> ("&middot;"), <code>&amp;bull;</code> ("&bull;") or <code>&amp;#124;</code> ("&#124;"), etc.
 
|-
 
|-
 
| <code>seealso</code>  
 
| <code>seealso</code>  
 
| enables link to the "See also" section
 
| enables link to the "See also" section
 
|-
 
|-
| <code>a</code> through <code>z</code>  
+
| <code>a</code> to <code>z</code>  
| individually disable particular letters that have no entries. ''Use with caution''  and check regularly to make sure that new entries do not require the removal of these parameters. Can also be used to create range links, e.g. "X-Z". ''(See [[#Letters]] below for more detailed documentation of this feature.)''
+
| disables individual letters that have no entries or creates range links,  for example, "X-Z". Use with caution and check regularly to make sure that new entries do not require the removal of these parameters.  
 +
|}
 +
 
 +
Any letter can be omitted (i.e. when it has no entries in the list) by using its ''lower-case'' parameter unset, for example, <code>q=</code>, or it can be replaced with an unlinked letter by using its ''lower-case'' parameter set to its ('''upper-case''') self, for example, <code>q=Q</code>.
 +
 
 +
It is sometimes better to create an empty place-holder span (e.g. <code><nowiki><span id="Q"/></nowiki></code>  where the letter's heading would be in the page if it existed, since  in  most cases it is quite possible that it will come to exist in the  future. Using the span-id avoids confusing new users who might not realize the TOC-template has skipped some letters.
 +
 
 +
The letter-assignment feature can also be used to create range links, for example, <code><nowiki>x=[[#X-Z|X-Z]]|y=|z=}}</nowiki></code>.
 +
 
 +
=== Examples ===
 +
 
 +
<code><nowiki>{{TOC}}</nowiki></code>
 +
{| style="margin-left:2.5em"
 +
|{{TOC}}
 +
|}
 +
 
 +
<code><nowiki>{{TOC|symnum=yes}}</nowiki></code>
 +
{| style="margin-left:2.5em"
 +
|{{TOC|symnum=yes}}
 
|}
 
|}
  
== Letters ==
+
<code><nowiki>{{TOC|side=yes|j=|q=}}</nowiki></code>
Any letter can be omitted (i.e. when it has no entries in the list) by specifying it as a ''lower-case'' blank parameter:&nbsp;
+
{| style="margin-left:2.5em"
<code>{{TOC|side&#61;yes|j&#61;|q&#61;}}</code>
+
{| style="margin-left:3.0em"
+
 
|{{TOC|side=yes|j=|q=}}
 
|{{TOC|side=yes|j=|q=}}
 
|}
 
|}
Or it can be replaced with an unlinked letter by using that letter ('''upper-case'''):
+
 
<code>{{TOC|side&#61;yes|j&#61;J|q&#61;Q}}</code>
+
<code><nowiki>{{TOC|side=yes|j=J|q=Q}}</nowiki></code>
{| style="margin-left:3.0em"
+
{| style="margin-left:2.5em"
 
|{{TOC|side=yes|j=J|q=Q}}
 
|{{TOC|side=yes|j=J|q=Q}}
 
|}
 
|}
''Note:'' It is often better to create an empty place-holder span (e.g. <code><nowiki><span id="Q" /></nowiki></code>  where the letter's heading would be in the page if it existed, since in  most cases it is quite possible that it will come to exist in the  future. Using the span-id avoids confusing new users who might not realize the TOC-template has skipped some letters.
 
  
The letter-assignment feature can also be used to create range links:
+
<code><nowiki>{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}</nowiki></code>
 
+
{| style="margin-left:2.5em"
<code>{{|TOC|side&#61;yes|x&#61;<nowiki>[[#X-Z|X-Z]]</nowiki>|y&#61;|z&#61;}}</code>
+
{| style="margin-left:3.0em"
+
 
|{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}
 
|{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}
 
|}
 
|}
 +
 +
[[Category:Navigational templates]]
 
</noinclude>
 
</noinclude>

Latest revision as of 22:34, 17 August 2011

Contents
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

The TOC template creates a replacement Table of Contents for alphabetical lists:

  • The "Contents" or a custom heading can go on top (default) or the side (side=yes).
  • letters can be omitted and/or merged into ranges: A B C-F G H-K L ...
  • Other options include: align=center, num=yes, top=yes, seealso=yes, etc.

Usage

{{TOC
|name    =
|side    = yes
|align   = center
|nobreak = yes
|top     = yes
|num     = yes
|sym     = yes
|symnum  =
|seealso = yes
|a       =
:
|z       =
}}
<!-- === <span id="A">A</span> ===
-->
<!-- === <span id="B">B</span> ===
-->
<!-- === <span id="C">C</span> ===
-->
<!-- === <span id="D">D</span> ===
-->
<!-- === <span id="E">E</span> ===
-->
<!-- === <span id="F">F</span> ===
-->
<!-- === <span id="G">G</span> ===
-->
<!-- === <span id="H">H</span> ===
-->
<!-- === <span id="I">I</span> ===
-->
<!-- === <span id="J">J</span> ===
-->
<!-- === <span id="K">K</span> ===
-->
<!-- === <span id="L">L</span> ===
-->
<!-- === <span id="K">K</span> ===
-->
<!-- === <span id="K">K</span> ===
-->
<!-- === <span id="M">M</span> ===
-->
<!-- === <span id="N">N</span> ===
-->
<!-- === <span id="O">O</span> ===
-->
<!-- === <span id="P">P</span> ===
-->
<!-- === <span id="Q">Q</span> ===
-->
<!-- === <span id="R">R</span> ===
-->
<!-- === <span id="S">S</span> ===
-->
<!-- === <span id="T">T</span> ===
-->
<!-- === <span id="U">U</span> ===
-->
<!-- === <span id="V">V</span> ===
-->
<!-- === <span id="W">W</span> ===
-->
<!-- === <span id="X">X</span> ===
-->
<!-- === <span id="Y">Y</span> ===
-->
<!-- === <span id="Z">Z</span> ===
-->

Parameters

Parameter Description
name replaces the "Contents" heading with an alternative name, or hide it completely by entering name=no
side places the "Contents" heading on the left side with a colon, instead of the top without one
align align=center aligns the TOC horizontal to the middle of the page; align=right aligns the TOC horizontally to the right of the page (may require <br style="clear:right;"/> after it, depending on page layout)
nobreak no linebreak between the letters and the "See also" link (note: does not affect the heading; use side for that)
top enables the "Top" link; this is only useful if this copy of the TOC is a secondary TOC not at the top of the page, e.g. in the middle of a long glossary
sym enables the "!$@" link for symbolic entries section
num enables the "0-9" link for numeric entries section (create a heading of ==0&ndash;9== for the link to work)
symnum enables the "!-9" link for combined symbolic and numeric entries section (create a heading of ==!&ndash;9== for the link to work)
sep sets the separator between the word-headers (but not the letters), for example &middot; ("·"), &bull; ("•") or &#124; ("|"), etc.
seealso enables link to the "See also" section
a to z disables individual letters that have no entries or creates range links, for example, "X-Z". Use with caution and check regularly to make sure that new entries do not require the removal of these parameters.

Any letter can be omitted (i.e. when it has no entries in the list) by using its lower-case parameter unset, for example, q=, or it can be replaced with an unlinked letter by using its lower-case parameter set to its (upper-case) self, for example, q=Q.

It is sometimes better to create an empty place-holder span (e.g. <span id="Q"/> where the letter's heading would be in the page if it existed, since in most cases it is quite possible that it will come to exist in the future. Using the span-id avoids confusing new users who might not realize the TOC-template has skipped some letters.

The letter-assignment feature can also be used to create range links, for example, x=[[#X-Z|X-Z]]|y=|z=}}.

Examples

{{TOC}}

Contents
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

{{TOC|symnum=yes}}

Contents
!-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

{{TOC|side=yes|j=|q=}}

Contents:
A B C D E F G H I K L M N O P R S T U V W X Y Z

{{TOC|side=yes|j=J|q=Q}}

Contents:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}

Contents:
A B C D E F G H I J K L M N O P Q R S T U V W X-Z