साचा:Chapter navigation with TOC
About
संपादनTemplate:Chapter navigation with TOC (or its redirect Template:Chapnavtoc) 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:
- Top of page: navigation for the previous, book name, next pages of the book.
- Bottom of page: navigation for previous page, book name, and next page of the book.
- It also provides an option to add a mini TOC (Table of Contents) at the bottom of the page.
- It adds by default a book category, and sorts category pages by chapter name.
Usage
संपादनBasic usage
संपादनAdd this once at the bottom of a page:
- {{chapter navigation with TOC|previous subpage name|next subpage name}}
You can instead use its redirect, which is simpler:
- {{chapnavtoc|previous subpage name|next subpage name}}
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:
- {{chapnavtoc||next subpage name}} for the first chapter
- {{chapnavtoc|previous subpage name}} for the last chapter
TOC usage
संपादनIt also provides an option to add a mini TOC (Table of Contents) at the bottom of the page, by using a third field:
- Create a subpage for a mini TOC, e.g. Book name/TOC mini
- 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:
{{chapnavtoc||Chapter 2|TOC mini}} (on Chapter 1 only)
{{chapnavtoc|Chapter 1|Chapter 3|TOC mini}} (on Chapter 2 only)
{{chapnavtoc|Chapter 2||TOC mini}} (on Chapter 3 only)
TOC mini coding
संपादन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
संपादन- By default it adds a book category. To disable this add the nocat=yes switch, for example:
- {{chapnavtoc|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>{{chapnavtoc|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.