Difference between revisions of "Template:TOC"

From Dragon Age Toolset Wiki
Jump to: navigation, search
m (Fixing table, fixing examples, adding category)
m (Cleaning up template)
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 -->
 
#ifeq:{{{name|}}}|no||! {{{name|{{MediaWiki:Toc}}}}}{{#ifeq:{{{side|}}}|yes|&#58;|}}
 
#ifeq:{{{name|}}}|no||! {{{name|{{MediaWiki:Toc}}}}}{{#ifeq:{{{side|}}}|yes|&#58;|}}
Line 15: Line 14:
 
<!-- 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>
 
{| style="margin-left:3.0em"
 
|{{TOC}}
 
|}
 
 
<code><nowiki>{{</nowiki>'''TOC'''|symnum=yes<nowiki>}}</nowiki></code>
 
{| style="margin-left:3.0em"
 
|{{TOC|symnum=yes}}
 
|}
 
=== Complete ===
 
  
 
<pre>
 
<pre>
Line 43: Line 29:
 
|name    =
 
|name    =
 
|side    = yes
 
|side    = yes
|center  = yes
 
|right  =
 
 
|align  = center
 
|align  = center
 
|nobreak = yes
 
|nobreak = yes
Line 58: Line 42:
  
 
=== Parameters ===
 
=== Parameters ===
 +
 
{| class="wikitable"
 
{| class="wikitable"
 
! Parameter !! Description
 
! Parameter !! Description
Line 68: Line 53:
 
|-
 
|-
 
| <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 77: Line 59:
 
|-
 
|-
 
| <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>  
Line 92: Line 74:
 
| 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.  
 
|}
 
|}
  
== Letters ==
+
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>.
Any letter can be omitted (i.e. when it has no entries in the list) by specifying it as a ''lower-case'' blank parameter: <code><nowiki>{{TOC|side=yes|j=|q=}}</nowiki></code>
+
 
{| style="margin-left:3.0em"
+
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}}
 +
|}
 +
 
 +
<code><nowiki>{{TOC|side=yes|j=|q=}}</nowiki></code>
 +
{| style="margin-left:2.5em"
 
|{{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><nowiki>{{TOC|side=yes|j=J|q=Q}}</nowiki></code>
+
 
{| style="margin-left:3.0em"
+
<code><nowiki>{{TOC|side=yes|j=J|q=Q}}</nowiki></code>
 +
{| style="margin-left:2.5em"
 
|{{TOC|side=yes|j=J|q=Q}}
 
|{{TOC|side=yes|j=J|q=Q}}
 
|}
 
|}
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:3.0em"
+
<code><nowiki>{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}</nowiki></code>
 +
{| style="margin-left:2.5em"
 
|{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}
 
|{{TOC|side=yes|x=[[#X-Z|X-Z]]|y=|z=}}
 
|}
 
|}
''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.
 
 
 
  
 
[[Category:Navigational templates]]
 
[[Category:Navigational templates]]
 
</noinclude>
 
</noinclude>

Revision as of 17:13, 14 August 2011

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       =
}}

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)
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