renekreupl / phoenix-headlinemarker
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
Type:typo3-cms-extension
pkg:composer/renekreupl/phoenix-headlinemarker
Requires
- php: ^8.2
- typo3/cms-backend: ^14.0
- typo3/cms-core: ^14.0
- typo3/cms-fluid: ^14.0
Requires (Dev)
- phpunit/phpunit: ^11.5 || ^12.0
- typo3/testing-framework: ^9.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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:
- The editor selects text in the headline field and clicks a button next to it.
- The field now reads
Room to learn. **Room to grow.**. That is also what is stored in the database. - 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
| Action | Result |
|---|---|
| Select text, click the button | Markers are placed around the selection, the selection stays |
| Click again on the same selection | The markers are removed |
| Selection starts or ends with spaces | The spaces stay outside of the markers |
| Nothing selected | Nothing 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>
| Argument | Default | Meaning |
|---|---|---|
value | tag content | Text with markers |
tag | strong | strong, b, span or em. Anything else falls back to strong |
class | empty | CSS class of that tag |
marker | extension configuration | Marker characters for this call |
plain | 0 | Remove the markers without adding a tag |
| Stored value | Output |
|---|---|
More **reach** for you | More <strong>reach</strong> for you |
**Two** parts **bold** | <strong>Two</strong> parts <strong>bold</strong> |
Open **without end | Open **without end |
Tom & **Jerry** | Tom & <strong>Jerry</strong> |
<b>**x**</b> | <b><strong>x</strong></b> |
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
plainin 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-nameattribute 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:
| Assumption | Result |
|---|---|
The visible input carries data-formengine-input-name | Confirmed in InputTextElement, the core password generator uses the same selector |
TCA options of a field control arrive in renderData/fieldControlOptions | Confirmed in the FieldControl container |
The FieldControl container translates title | Confirmed, the control returns the LLL: reference |
A ViewHelper with render() and $this->arguments works with Fluid 5 | renderStatic() is not used |
Content Blocks pass fieldControl from YAML into the TCA | Confirmed 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.