Template:Chapter navigation with TOC

From Wikibooks, open books for an open world
Jump to navigation Jump to search
Template documentation[edit] [history] [purge]

About[edit]

This is a fork of Template:Chapter navigation; it was forked to avoid any legacy issues arising from changing its code.

It uses CSS and JavaScript to position chapter navigations at both the top and bottom of a page.

The template adds:

  1. Top of page: navigation for the previous, book name, next pages of the book.
  2. Bottom of page: navigation for previous page, book name, and next page of the book.
  3. It also provides an option to add a mini TOC (Table of Contents) at the bottom of the page.
  4. It adds by default a book category, and sorts category pages by chapter name.

Usage[edit]

Basic usage[edit]

Add this once at the bottom of a page:

Note that the "previous subpage name" and "next subpage name" fields are both optional.

For first and last chapter of a book, leave the first or second field blank respectively:

TOC usage[edit]

It also provides an option to add a mini TOC (Table of Contents) at the bottom of the page, by using a third field:

  1. Create a subpage for a mini TOC, e.g. Book name/TOC mini
  2. Link the subpage in the third field

For the book "Example book", you would add TOC mini at "Example book/TOC mini". With three chapters "Example book/Chapter 1", "Example book/Chapter 2", "Example book/Chapter 3", you would place the following once at the bottom of the page of each corresponding chapter:

{{Chapter navigation with TOC||Chapter 2|TOC mini}} (on Chapter 1 only)

{{Chapter navigation with TOC|Chapter 1|Chapter 3|TOC mini}} (on Chapter 2 only)

{{Chapter navigation with TOC|Chapter 2||TOC mini}} (on Chapter 3 only)

TOC mini coding[edit]

The recommended coding for TOC mini is:

<small>{{nowrap begin}}<!--

-->[[Book name/Chapter 1|Chapter 1]]{{·w}}<!--
-->[[Book name/Chapter 2|Chapter 2]]{{·w}}<!--
-->[[Book name/Chapter 3|Chapter 3]]{{·w}}<!--
-->[[Book name/Chapter 4|Chapter 4]]{{·w}}<!--
-->[[Book name/Chapter 5|Chapter 5]]<!--

-->{{nowrap end}}</small><!--

--><noinclude>{{bookcat}}</noinclude>

Where [[Book name/Chapter 1|Chapter 1]] etc. are replaced with the correct data. The above example would produce:

Chapter 1 · Chapter 2 · Chapter 3 · Chapter 4 · Chapter 5

It is normally created at Book name/TOC mini. See Template:Nowrap begin for no-wrap documentation.

Advanced tips[edit]

  • By default it adds a book category. To disable this add the nocat=yes switch, for example:
{{Chapter navigation with TOC|previous subpage name|next subpage name|TOC mini|nocat=yes}}
Be aware that if you are using a TOC mini, any category from there will be transcluded, unless it is wrapped with noinclude tags.
  • If transcluded into Book name/Print version, the template should not be displayed nor printed. But otherwise you can prevent transclusion by wrapping with noinclude tags, for example:
<noinclude>{{Chapter navigation with TOC|previous subpage name|next subpage name|TOC mini}}</noinclude>
  • If looking at Wikibooks with "Mobile view" (there is a link at the bottom of every Wikibooks page), the top navigation will not appear, as this is not possible in mobile view. The top navigation should also not appear on the main page.

Example[edit]

See also[edit]