Quicktoc


(click to open)

Quick Page Table of Contents

Scanning...

Summary: Adds a dropdown clickable table of contents to a page - client side processing Version: 1.12, September 4, 2006 Status: Stable Prerequisites: pmwiki 2.1 and above Maintainer: Henrik Bechmann (henrik [period] bechmann [snail] sympatico [period] ca) Categories: Markup, TOC, Layout Download: Attach:quicktoc.zip

Questions answered by this recipe

(click to open)

Quick Page Table of Contents

Scanning...

How to add an automatic table of contents to a wiki page.

Description

This is DHTML (css/html/javascript). The author adds (:quicktoc:) to the wiki source text. The reader sees a collapsed table of contents bar. When the user clicks the bar, the javascript included in the page searches the immediate children of div#wikitext for header elements (h1, h2, h3, h4, h5, h6), and lists these as page links. The table of contents drops over page text, rather than displacing it, and is dismissed when it is clicked.

Example:

Quick Page Table of Contents as first presented to the user:

Attach:quicktocclosed.jpg Δ


Quick Page Table of Contents after the user clicks on the bar:

Attach:quicktocopen.jpg Δ


Try it yourself here

Notes

Installation
  1. Download the attached file (Attach:quicktoc.zip) to your PmWiki root directory (the one just above cookbook and pub directories). Unzip it. This should result in the following distribution: quicktoc.php in cookbook/; and arrowdown.gif, arrowright.gif, disc.gif, quicktoc.css, and quicktoc.js in pub/quicktoc/.
  2. Add the following line to your config.php file: include_once('cookbook/quicktoc.php');
Usage

Add the directive (:quicktoc:) to any wikipage that would benefit from a quick table of contents, usually at the top (the toc floats right).

Release Notes

Version 1.12 Fourth release, September 4, 2006. Modified javascript and css to remove need to specify url for dynamic change to down/right arrow on open/close.

Version 1.11 Third release, August 31, 2006. Repackaged the PmWiki way, much simplifying installation (thanks to Patrick Michaud for direction on this). Added default font size of 9pt.

Version 1.1 Second release, August 30, 2006: menu drops down over text, and is dismissed when clicked anywhere. Top level headings are bolded. TOC title includes "click to open" when closed, and "click to close" when open.

Version 1.0 First release, June 10, 2006

Comments

I installed quicktoc (Sept-06) in PmWiki2?.1.26 and seem to have one anomaly. On this demo page, the dropdown appears as a one-line option with Quick Page Table of Contents followed by (Click to Open) in a box with a grey background.

On my wiki, the quicktoc function operates as expected, but the dropdown box appears on 2 lines. On the first line, the (Click to Open) option appears right justified on the upper line, with a white background, while the Quick Page Table of Contents appears on the lower line, left justifed and with a grey background.

Formatting is the same using Explorer or Firefox Des September 16, 2006, at 03:07 PM

  • Just experimented and found a quick fix for myself. Added clear:none to the css for h1#quicktocheading but this may not be the ideal fix. Des September 16, 2006, at 03:07 PM
  • I changed in the file quicktoc.php and quicktoc.css "h1" to "h4" and all was fine! January 10, 2007, at 09:07 AM

Also, after comparing the operation on my test page http://www.secretscotland.org.uk/index.php/Secrets/AABatteriesClyde with this page, I've also noticed that the vertical aligment of the header content differs AND this demo page does not display the right or down arrow in the header dropdown, but it does appear on my own page. Des September 16, 2006, at 03:14 PM

See Also

PmWiki /
TableOfContents  Basic automatic table of contents and numbered headings
Cookbook /
Accordion  lightweight Accordion javascript requiring no framework (stable)
AutoTOC  Unobtrusive Automatic Table of Contents links (stable)
HandyTableOfContents  Handy Client-side Table of Contents (stable)
NumberedHeaders  Display numbered headers, indented paragraphs and table of contents (Stable)
NumberedSections  Add section numbers on a page (stable)
PageTableOfContents  Adds a clickable table of contents to a page (Stable)
QuickPageTableOfContents  Adds a dropdown clickable table of contents to a page - client side processing (Stable)
SlimTableOfContents  Simple or Numbered Table of Contents, Compatible with SectionEdit? Recipe (not working with php5.5)

Contributors

 0: 00.00 00.00 config start
 1: 00.01 00.01 config end
 2: 00.11 00.11 MarkupToHTML begin
 3: 00.13 00.13 ReadApprovedUrls SiteAdmin.ApprovedUrls begin
 4: 00.13 00.13 ReadApprovedUrls SiteAdmin.ApprovedUrls end
 5: 00.18 00.18 FPLTemplate: Chain begin
 6: 00.18 00.18 FPLTemplate: FPLTemplateLoad
 7: 00.18 00.18 FPLTemplate: FPLTemplateDefaults
 8: 00.18 00.18 FPLTemplate: FPLTemplatePageList
 9: 00.18 00.18 MakePageList pre
10: 00.18 00.18 PageListSources begin
11: 00.18 00.18 PageStore::ls begin wiki.d/{$FullName}
12: 00.19 00.18 PageStore::ls merge wiki.d/{$FullName}
13: 00.19 00.18 PageStore::ls end wiki.d/{$FullName}
14: 00.19 00.18 PageStore::ls begin $FarmD/wikilib.d/{$FullName}
15: 00.19 00.18 PageStore::ls merge $FarmD/wikilib.d/{$FullName}
16: 00.19 00.18 PageStore::ls end $FarmD/wikilib.d/{$FullName}
17: 00.19 00.18 PageListSources end count=1
18: 00.19 00.18 PageListSort pre ret=4 order=name
19: 00.19 00.18 MakePageList items count=1, filters=
20: 00.19 00.18 MakePageList post count=1, readc=0
21: 00.19 00.19 PageListSort begin
22: 00.19 00.19 PageListSort sort
23: 00.19 00.19 PageListSort end
24: 00.19 00.19 MakePageList end
25: 00.19 00.19 FPLTemplate: FPLTemplatePmWikiOrg
26: 00.19 00.19 MarkupToHTML begin
27: 00.19 00.19 MarkupToHTML end
28: 00.19 00.19 FPLTemplate: FPLTemplateSliceList
29: 00.19 00.19 FPLTemplate: FPLTemplateFormat
30: 00.19 00.19 MarkupToHTML begin
31: 00.19 00.19 MarkupToHTML end
32: 00.19 00.19 FPLTemplate: FPLTemplatePmWikiOrgPostFormat
33: 00.19 00.19 FPLTemplate: Chain end
34: 00.19 00.19 FPLTemplate: Chain begin
35: 00.19 00.19 FPLTemplate: FPLTemplateLoad
36: 00.20 00.19 FPLTemplate: FPLTemplateDefaults
37: 00.20 00.19 FPLTemplate: FPLTemplatePageList
38: 00.20 00.19 MakePageList pre
39: 00.20 00.19 PageListSources begin
40: 00.20 00.19 PageStore::ls begin wiki.d/{$FullName}
41: 00.20 00.19 PageStore::ls merge wiki.d/{$FullName}
42: 00.21 00.20 PageStore::ls end wiki.d/{$FullName}
43: 00.21 00.20 PageStore::ls begin $FarmD/wikilib.d/{$FullName}
44: 00.21 00.20 PageStore::ls merge $FarmD/wikilib.d/{$FullName}
45: 00.21 00.20 PageStore::ls end $FarmD/wikilib.d/{$FullName}
46: 00.21 00.20 PageListSources end count=10152
47: 00.21 00.20 PageListTermsTargets begin count=10152
48: 00.21 00.20 PageIndexGrep begin
49: 00.24 00.22 PageIndexGrep end
50: 00.24 00.23 PageListTermsTargets end count=8
51: 00.24 00.23 PageListSort pre ret=4 order=name
52: 00.24 00.23 MakePageList items count=8, filters=PageListTermsTargets
53: 00.24 00.23 MakePageList post count=8, readc=8
54: 00.24 00.23 PageListSort begin
55: 00.24 00.23 PageListSort sort
56: 00.24 00.23 PageListSort end
57: 00.24 00.23 MakePageList end
58: 00.24 00.23 FPLTemplate: FPLTemplatePmWikiOrg
59: 00.24 00.23 MarkupToHTML begin
60: 00.24 00.23 MarkupToHTML end
61: 00.24 00.23 FPLTemplate: FPLTemplateSliceList
62: 00.24 00.23 FPLTemplate: FPLTemplateFormat
63: 00.25 00.23 MarkupToHTML begin
64: 00.25 00.24 MarkupToHTML end
65: 00.25 00.24 FPLTemplate: FPLTemplatePmWikiOrgPostFormat
66: 00.25 00.24 FPLTemplate: Chain end
67: 00.26 00.24 MarkupToHTML end
68: 00.26 00.24 MarkupToHTML begin
69: 00.27 00.25 MarkupToHTML end
70: 00.27 00.26 MarkupToHTML begin
71: 00.28 00.26 MarkupToHTML end
72: 00.28 00.26 now
Peak memory: 6,159,160 bytes