Custom TOC
No security coverage
Custom TOC allows editors to create and manage tables of contents within Drupal. It offers a field type that stores editable TOC markup, and a CKEditor widget to generate a starter TOC from a chosen source field, enabling editors to refine link text for each page. The formatter then displays the saved TOC, ensuring consistency between the draft and published content.
Overview
Custom TOC provides a field type that stores editable Table of Contents markup. The CKEditor widget can generate a starter TOC from a chosen source field and lets editors refine link text per page. The formatter renders the saved TOC so the published page matches the stored field value.
Features
- Generate a TOC from headings and edit link text per node.
- Keep TOC output stable across view modes.
- Handle missing or removed fields safely.
Requirements
- Drupal core 10 or 11.
- toc_api module enabled.
Installation
- Enable the module.
- Add the "TOC (CKEditor)" field to a content type.
- Select a formatted text source field (text processing enabled).
Configuration
- Choose the source field for heading extraction.
- Set allowed text formats and a default format.
- Configure toc_api "TOC type" settings for headings and template.
Usage
- Create or edit content with headings in the source field.
- Click "Regenerate TOC" to build the initial markup.
- Optionally edit the TOC HTML, then save the node.
Notes
- Avoid enabling toc_api_example to prevent heading id changes on view.