Allow multiple text fields within the API

Created on 18 September 2017, almost 8 years ago
Updated 30 June 2025, 29 days ago

We're currently working on a Drupal site using the Paragraphs module, having easy content editing for non-HTML-experienced content editors in mind.

The paragraphs module allows adding multiple paragraph entities to a node which compose the content. Each paragraph is referenced either by entity reference or entity reference revision fields and may contain rich text fields as well.

Especially for long nodes with a huge amount of paragraphs (e.g. one-pager), we'd love to have automatically built ToCs out of the parsed rich text areas or even dedicated paragraph title fields (which we use to add headlines to carousels/tabbed sections).

The available contrib modules for ToCs are not really useful for this approach, as they still need quite some work an unexperienced content editor may do wrong.

Having digged a little into the toc_api module, we found the approach is worth working with. But it currently works for one field only. A ToC composed out of multiple rendered HTML fields won't work.

Therefore we suggest adding a feature to toc_api, allowing to add multiple markup to the class before the TOC is rendered, hence making the content property of the Toc class an assoc array, whereas the toc manager gets an "addContent" method which returns the id of that content part.

When building the ToC, the toc builder iterates over that array in the order of contents added to the class.

We understand that it is a major rewrite of some API features, but find it would make the API more flexible and usable even for our use case.

We didn't like to do this work in a fork of your module without having asked the community first, whether others would find it useful too. Then we could contribute our solution to your module later and keep the namespace...

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

🇭🇰Hong Kong Mario Steinitz Hong Kong Central

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024