Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define custom class, title, and target in Link Browser for content elements and the new rte_ckeditor?

Prerequisites

[x] Can you reproduce the problem on TYPO3 8.7 LTS - YES

[x] Did you [perform a cursory search] to see if your bug or enhancement is already reported? -YES

Description

How do I configure default link target, class, and title for the Link Browser in any element link (usually element titles and images) AND in rte_ckeditor in Typo3 8 LTS? I've spent several hours trying to configure it, but no success and no documentation out there. The fields are empty as you can see on the images below.

enter image description here enter image description here

Steps to Reproduce the problem

  1. Create any element that you can link the title or image.
  2. Click to open the Link Browser
  3. The options come empty for any type of link (Page, File, Folder, External URL, Email).

Expected behavior: I want to define default classes, link targets and titles for each type of link if they are empty. For example External URL, I want to automatically populate with target="_blank", class "external-link", title="Link to External Website", if the link wasn't configure previously. Basically for any new link I just want to have it auto populated with my custom values and not empty values.

This used to work for rtehtmlarea only on previous Typo3 versions, but not I'm not able to set this option system wide on Typo3 8 LTS and ckeditor.

The PageTS that used to work only for rtehtmlarea was something like this:

RTE {
    classesAnchor {
        externalLink {
            class = external-link
            type = url
            titleText = Opens external link in new window
            target = _blank
            image =
        }
        externalLinkInNewWindow {
            class = external-link-new-window
            type = url
            titleText = Opens external link in new window
            target = _blank
            image =
        }
        internalLink {
            class = internal-link
            type = page
            titleText =  Opens internal link in this window
            target = _top
            image =
        }
        internalLinkInNewWindow {
            class = internal-link-new-window
            type = page
            titleText = Opens internal link in new window
            target = _blank
            image =
        }
        folder {
            class = folder
            type = folder
            titleText =
            target =
            image =
        }
        download {
            class = download
            type = file
            titleText = Initiates file download
            target = _blank
            image =
        }
        mail {
            class = mail
            type = mail
            titleText = Email Address
            image =
        }
    }
}

I would like this to work for the new rte_ckeditor as well for any element options that I can link using the Link Browser.

like image 620
mvetter Avatar asked Sep 01 '25 22:09

mvetter


1 Answers

There is a bug in TYPO3 8.7.8 (only) - see: https://forge.typo3.org/issues/82865

[EDIT] the classesAnchor stuff works only in version 8.7.5 to 8.7.7 and will hopefully work again in 8.7.9

But the correct answer whould be (like Ghanshyam Bhava pointed out in his comment) to switch to YAML configuration.

https://typo3worx.eu/2017/02/configure-ckeditor-in-typo3/

# Load default processing options
imports:
    - { resource: "EXT:rte_ckeditor/Configuration/RTE/Default.yaml" }

classesAnchor:

  externalLink:
    class: 'external-link'
    type: 'url'

  downloadLink:
    class: 'download-link'
    type: 'file'

  mailLink:
    class: 'mail-link'
    type: 'mail'

buttons:
  link:
    properties:
      class:
        allowedClasses: 'external-link,download-link,mail-link'

Link Browsers for other fields outside RTE should be possible via TCA-Overrides.

like image 186
Tobias Gaertner Avatar answered Sep 04 '25 01:09

Tobias Gaertner