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