Table of Contents
This module generates a table of contents and corresponding links to headings within a document. All of the work is done through the input filter system.
Available translations: French (complete), Polish (not up to date in 3.x)
The Drupal 6 version of this module is currently maintained by Alexis Wilke.
We are looking for someone to help for version 5.x if you are interested, post an issue about that...
WARNING
I changed MANY things in version 3.x-dev (Please use Jul 6, 2009 version!). It works for me... but you probably want to check and make sure that it works for you too! And read the following too:
DO NOT FORGET TO MAKE A BACKUP OF YOUR DATABASE & CODE
- FIRST: Remove the module from your website (there is no need to remove the tags from your nodes, however! Keep those!)
- Make sure to DELETE your existing tableofcontents folder
- Extract the new version of the module
- Reinstall on your website (yes, the Anchors module is gone and the package name is now "Filter inputs" as intended a while back.)
- Enjoy!
This newer version fixes most of the problems with the TOC module. There are still 3 issues for v6.x. Things that are more like features than bugs.
The major modification is with the headinganchors module. It was removed. The new version of the module is MUCH faster and completely out of the way if you do not use that module (filter) in a certain node type (depends on the format chosen...)
WARNING: if you wrote your own theme function, it's broken now. The new function receives an object with all the options as members and the $toc->headers includes the list of anchors you want to create in your table of contents. You'll have $toc->files with the array of attachments.
I will create a document to explain in much details how to use the module version 3.x+.
Don't hesitate to reopen issues that do not work for you! Marking them fixed makes me feel good, that's all. But it's not forbidden to complain! 8-)
Of note, if you are using FCKeditor (and possibly another WYSIWYG editor), by default, it will change accentuated letters such as é into its corresponding HTML entity, é. That means the table of content will most certainly not work as expected. To fix the problem, change the ProcessHTMLEntities as following:
FCKConfig.ProcessHTMLEntities = false ;
More info: ProcessHTMLEntities.
Known issues
The HTML Filter will remove <script> tags which means you won't get the table to work properly. Please, make sure that the HTML Filter appears BEFORE the table of contents so it works as expected.
When asking the toc system to add numbering to your anchors, it will do so to all the anchors whether or not the toc tags or settings specify a minimum and maximum. This means the resulting numbers in your table of contents may not look correct (i.e. if the minimum level is H2 and you have some H1 tags, the numbers will, for instance, start at 1.1 instead of 1.0 and then the next H2 is shown as 1.2, instead of 2.0 as you'd expect in your table of content.) Note that the title of the page (often H1) is NOT included in your table of contents so that should have no effect here.
Note about heading levels
This module supports choosing the minimum and maximum heading levels for a table of contents. This can cause unexpected output in your page if, for example, the minimum level is set to "h2" and your headings start at "h3". Please see the README documentation for more details.
The very problem described in the previous paragraph was fixed in version 3.x-dev
The newer versions (3.x-dev, 3.1+) eliminates all the headers that are outside the scope of your TOC. For instance, you can ask to get levels 3, 4 and 5. That means levels 1, 2 and 6 will NOT appear in your TOC. It may be surprising because a page with just H2 headers and a [toc ...] that starts at level 3 will result in no TOC at all (i.e. since no headers match, there is no need for a TOC and thus the module returns an empty string...)
