Search by

renekreupl / phoenix-headlinemarker

renekreupl

Bold parts in single line TYPO3 headline fields: a button on the field and a Fluid ViewHelper

Package info

gitlab.com/phoenix-ext/phoenix_headlinemarker

Issues

Type:typo3-cms-extension

pkg:composer/renekreupl/phoenix-headlinemarker

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

v1.0.0 2026-12-04 00:02 UTC

This package is not auto-updated.

Last update: 2026-12-04 05:20:53 UTC


README

Bold parts in single line TYPO3 headline fields, without a rich text editor and without a second field.

Many designs mix a light and a bold weight in one headline: "Room to learn. Room to grow." The usual workarounds are two fields (which part comes first?), a rich text editor for one line, or HTML typed into an input field. This extension takes a smaller route:

  1. The editor selects text in the headline field and clicks a button next to it.
  2. The field now reads Room to learn. **Room to grow.**. That is also what is stored in the database.
  3. A ViewHelper turns the markers into <strong> in the frontend and escapes everything else.

The field stays a normal type=input. There is no custom render type, no XCLASS and no core patch.

Installation

TYPO3 14 and PHP 8.2 or later. Composer mode:

composer require renekreupl/phoenix-headlinemarker

Then flush the caches:

vendor/bin/typo3 cache:flush

If your headline fields are defined in another extension, add the package to the requirements of that extension as well, so the load order is right:

{
    "require": {
        "renekreupl/phoenix-headlinemarker": "^1.0"
    }
}

Activate the button on a field

The button is opt-in per field. Nothing changes until you switch it on.

TCA

For the core headline of content elements, in Configuration/TCA/Overrides/tt_content.php of your extension:

<?php

defined('TYPO3') or die();

$GLOBALS['TCA']['tt_content']['columns']['header']['config']['fieldControl']['boldMarker'] = [
    'renderType' => 'phoenixHeadlinemarkerControl',
];

Any other type=input column works the same way.

Content Blocks

Content Blocks pass fieldControl through to the TCA:

fields:
  - identifier: headline
    type: Text
    fieldControl:
      boldMarker:
        renderType: phoenixHeadlinemarkerControl

For a reused core field such as header, activate it once with the TCA override above.

Using the button

ActionResult
Select text, click the buttonMarkers are placed around the selection, the selection stays
Click again on the same selectionThe markers are removed
Selection starts or ends with spacesThe spaces stay outside of the markers
Nothing selectedNothing happens
Result would exceed the field length (max)Nothing happens

Typing the markers by hand works just as well.

ViewHelper

Declare the namespace in the Fluid template:

<html xmlns:hm="http://typo3.org/ns/ReneKreupl/PhoenixHeadlinemarker/ViewHelpers" data-namespace-typo3-fluid="true">

<h2><hm:boldMarker value="{data.header}" /></h2>

<h2>{data.header -> hm:boldMarker(class: 'headline__accent')}</h2>

</html>
ArgumentDefaultMeaning
valuetag contentText with markers
tagstrongstrong, b, span or em. Anything else falls back to strong
classemptyCSS class of that tag
markerextension configurationMarker characters for this call
plain0Remove the markers without adding a tag
Stored valueOutput
More **reach** for youMore <strong>reach</strong> for you
**Two** parts **bold**<strong>Two</strong> parts <strong>bold</strong>
Open **without endOpen **without end
Tom & **Jerry**Tom &amp; <strong>Jerry</strong>
<b>**x**</b>&lt;b&gt;<strong>x</strong>&lt;/b&gt;

Every part of the text is escaped on its own, so no HTML from the field reaches the page.

Plain text mode

Wherever HTML is not allowed, remove the markers:

<img src="..." alt="{hm:boldMarker(value: data.header, plain: 1)}" />

<f:link.page pageUid="{page.uid}" title="{hm:boldMarker(value: page.header, plain: 1)}">…</f:link.page>

The output is escaped here too, so do not escape it a second time.

Configuration

The marker is **. Change it for the whole installation in the extension configuration (Admin Tools > Settings > Extension Configuration > phoenix_headlinemarker), or in config/system/settings.php:

'EXTENSIONS' => [
    'phoenix_headlinemarker' => [
        'marker' => '~~',
    ],
],

A single field can use its own marker with 'options' => ['marker' => '~~'] on the field control. The ViewHelper then needs the same marker argument.

Changing the marker does not rewrite existing content.

Limitations

  • The markers are part of the stored value. Everywhere the field is printed without the ViewHelper the characters are visible: page titles, meta tags, menus, search index, alt texts, and in the backend the page module and list module. Use plain in the frontend.
  • One marker, one meaning: there is no second style such as italic.
  • Markers cannot be nested and a marked part cannot span two lines. Fields with two lines should be two fields.
  • The backend script finds the input through the data-formengine-input-name attribute of FormEngine. This is the one place which can break with a major TYPO3 update, and it lives in one file.

Compatibility

TYPO3 14 only (typo3/cms-core: ^14.0), PHP 8.2 or later. Tested on TYPO3 14.3.

The following points of the FormEngine and Content Blocks behaviour were checked against the source code of TYPO3 14.3.7 with Content Blocks 2.4.9:

AssumptionResult
The visible input carries data-formengine-input-nameConfirmed in InputTextElement, the core password generator uses the same selector
TCA options of a field control arrive in renderData/fieldControlOptionsConfirmed in the FieldControl container
The FieldControl container translates titleConfirmed, the control returns the LLL: reference
A ViewHelper with render() and $this->arguments works with Fluid 5renderStatic() is not used
Content Blocks pass fieldControl from YAML into the TCAConfirmed in WithCommonProperties

Tests

Unit tests run with PHPUnit and typo3/testing-framework. In the repository folder:

composer install
vendor/bin/phpunit

License

GPL-2.0-or-later. See LICENSE.