Digitales

TYPO3 HowTo: Using a custom rte_ckeditor configuration in DCE

Sometimes you want to create a textarea in Dynamic Content Elements (DCE), but for this specific element you don't want the client/editor to use the full range of options the Rich-Text Editor (RTE) has to offer. For this scenario I've written this guide to help you create a custom, cleaner experience in just a few simple steps. 

I recently found myself with the scenario where I needed a custom RTE interface, but stripped down and focussed on creating tables for product information. I decided I wanted to create a custom textarea for this usage only, because I only really needed a few editing options. If you are looking for an easy way to create a custom configuration for your rte_editor, and use this in DCE, continue reading!

Erik de Kuijper
2022-02-18
WCG GmbH & Co.KG

For this tutorial I assume you are working with rte_ckeditor. At the time of writing I used TYPO3 8, and should work for upcoming versions as well.

This is what we need to do:

  • Add a new RTE Preset
  • Create a custom YAML configuration
  • Use the preset in DCE

Let's get to it!

Add a new RTE Preset

If you don't have one already, create a new AdditionalConfiguration.php file in your typo3conf folder. In this file we're going to add a new configuration preset. Feel free to change the preset name and path to whatever suits your need.

<?php
$GLOBALS['TYPO3_CONF_VARS']['RTE']['Presets']['customEditor'] = 'fileadmin/rte/customEditor.yaml';
?>

ProTip: Just repeat this line if you want to add multiple configurations.

Create a custom YAML configuration

In the location you decided on in the snippet above, create the customEditor.yaml file. I suggest you start with a base template. Luckily the ckeditor comes with a few templates to start from. You can find these in the following location:

typo3/sysext/rte_ckeditor/Configuration/RTE/

Here are a few base templates we can copy to our file. Default, Full, or Minimal.yaml. I went with minimal, and added a few buttons based on the Full template.

# Load default processing options
imports:
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Processing.yaml" }
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Editor/Base.yaml" }
# Minimal configuration for the editor
editor:
  config:
    toolbarGroups:
      - { name: basicstyles, groups: [ basicstyles] }
      - { name: clipboard, groups: [clipboard, undo] }
      - { name: insert }
      - { name: document,  groups: [ mode, document, doctools ] }
    removeButtons:
      - Anchor
      - Superscript
      - Subscript
      - Underline
      - Strike
      - SpecialChar
      - HorizontalRule
      - Image

This configuration adds the Table, and Source Code button to the minimal layout.

Use the preset in DCE

Now in your DCE module, add a normal RTE Textarea. And simply use your newly created preset in the configuration.

<config>
  <type>text</type>
  <rows>5</rows>
  <cols>30</cols>
  <eval>trim</eval>
  <enableRichtext>1</enableRichtext>
  <richtextConfiguration>customEditor</richtextConfiguration>
</config>

Here's one last tip, if you didn't know this already. Remember the base templates provided by rte_ckeditor? You can use these base templates in DCE right now, by simply changing your richtextConfiguration to Default, Full, or Minimal.

Interessiert an unseren TYPO3 Lösungen?

Newsletter

Erhalten Sie monatlich News rund um die Themen:

Unternehmensführung, Marke, Ertragssteigerung, Mitarbeiterbindung, Digitalisierung, CSR

Kontakt aufnehmen

WCG®
Garnisonsring 33
57072 Siegen
Germany

info@wcg.de
Phone +49 271 3135-0
Fax +49 271 3135-199
WCG Seit 1993

Auszeichnungen

Auszeichnungen sind ein Qualitätsmerkmal! Überzeugen Sie sich selbst!

Social-Media

Finden Sie uns im Bereich Social Media. Folgen Sie uns, um tagesaktuell informiert zu werden.