|
Cookbook /
HandyTableOfContentsSummary: Handy Client-side Table of Contents
Version: 20070218
Prerequisites: PmWiki version 2.1.27
Status: beta
Maintainer: Kathryn Andersen
File: handytoc.zipΔ
Questions answered by this recipeHow can I create a table of contents for included files? How can I create a table of contents for a page whose content is generated via pagelist? DescriptionMost of the existing table-of-contents recipes have this limitation: they can only generate a table of contents from the information in the source of the page they're used in. If data is included later (either with (:include :), or, even more tricky, with IncludeUpload) then they don't have the data to base the table-of-contents on. This recipe solves that problem by generating the table-of-contents with JavaScript, which is run after the page has finished loading, so all the data is there. Of course, the downside is that it requires JavaScript to be turned on; which many users and browsers may not. Caveat emptor. NotesActivationTo activate this recipe, unzip the archive; this will create a handytoc-(version) directory; you then need to move or copy the contents of this into your pmwiki directory. The directory contains:
Add the following line to your local/config.php:
include_once("$FarmD/cookbook/handytoc.php");
UsageThe simplest usage is to just put the You can add a title to your table of contents simply by adding it to the directive: (:htoc This is my table of contents:) There are also options.
Examples(:htoc start=2:) The above will start with h2 headers. (:htoc end=3:) The above will end at h3 headers. Note that if there are no H1 headers inside the content at all, then the table-of-contents will start at level 2 automatically, even of the headers are in an odd order. Configuration variablesThese can be set in local/config.php
CSS StylingThe table of contents is put inside a div with id='htoc', and the table-of-contents title (if there is one) is put in a H3 header. While the recipe comes with its own CSS styling (in pub/handytoc/handytoc.css) this can be overridden with your own custom CSS in pub/css/local.css If the "class=" option is used, then the class is set for the same div; that is, it will be <div id="htoc" class="classname"> so keep that in mind when using this option. There is also a .htoneline (handy-toc one line) class in the CSS file, which can be used (with the "class=" option) to make the table-of-contents all on one line, with | separators between each item. This is useful for pages where the headers are, say, single letters of the alphabet (as may happen with indexes). The CSS for this, however, may not work in less-advanced browsers. LimitationsThis does not have a show/hide button like some of the other TOC recipes; if it's defined for that page, then it's there all the time. If you want to show and hide the toc, you can use the Show Hide recipe with markup such as the following: (:showhide init=hide div=htoc lshow='Show Table of Contents' lhide='Hide Table of Contents':) Note that this recipe will not work if the skin you are using does not have <!--HTMLFooter--> markup in it. Release Notes
CommentsSee AlsoContributorsSandbox |