sebkln / content_slug

Adds a slug field for human-readable anchors ("domain.com/page/#my-section") to TYPO3 content elements. By default, this anchor is rendered as the header's id attribute.
GNU General Public License v2.0
11 stars 5 forks source link

Button to generate fragment identifier from current header #2

Closed sebkln closed 3 years ago

sebkln commented 4 years ago

Similar to the pages' slug field: provide a button that allows the editor to generate an anchor from the contents of the header field.

nostadt commented 4 years ago

Why not using the core slug field? https://docs.typo3.org/m/typo3/reference-tca/master/en-us/ColumnsConfig/Type/Slug.html

sebkln commented 4 years ago

Thanks for the hint. I actually started with the slug TCA type, but it had some disadvantages.

I also wrote about it on my blog. Excerpt:

In a first attempt, I had used a TCA field of the type "slug" instead. This seemed promising–I was able to configure the TCA to fill my new fragment field with the contents of the header field. Just like the slug field for pages, an editor could also perform this by clicking a button next to the field. But it had two disadvantages: first, the fragment field became mandatory by this, which might not always be desirable. Second, the slug evaluation filtered out some characters–but not the slash, for example. And the slash cannot be used in URL fragments.

Current status

The button is already in place, implemented as described here. I also added a custom PSR-7 Ajax route for the backend and tried to familiarize myself with RequireJS.

The work on this is currently paused though, as I work on a relaunch of my blog.

nostadt commented 4 years ago

I see. Thanks for the response. Quite some text. Will check that asap.

The work on this is currently paused though, as I work on a relaunch of my blog.

Nice