Quicktoc


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)
PmWiki /
TableOfContents-Talk  

Contributors

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