Project

General

Profile

Actions

Bug #80971

closed

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

Added by Marcelo Vetter almost 7 years ago. Updated over 3 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Link Handling, Site Handling & Routing
Target version:
-
Start date:
2017-04-24
Due date:
% Done:

70%

Estimated time:
TYPO3 Version:
8
PHP Version:
Tags:
link-browser, ckeditor
Complexity:
medium
Is Regression:
Sprint Focus:

Description

Prerequisites

  • [x] Can you reproduce the problem on TYPO3 8.7 LTS
  • [x] Did you [perform a cursory search] to see if your bug or enhancement is already reported?

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? 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.

Steps to Reproduce

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
}
externalLinkInNewWindow {
class = external-link-new-window
type = url
titleText = Opens external link in new window
target = _blank
}
internalLink {
class = internal-link
type = page
titleText = Opens internal link in this window
target = _top
}
internalLinkInNewWindow {
class = internal-link-new-window
type = page
titleText = Opens internal link in new window
target = _blank
}
folder {
class = folder
type = folder
titleText =
target =
}
download {
class = download
type = file
titleText = Initiates file download
target = _blank
}
mail {
class = mail
type = mail
titleText = Email Address
}
}
}
```
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.


Related issues 1 (0 open1 closed)

Is duplicate of TYPO3 Core - Bug #81381: RTE TSConfig is lost when using own CKEditor presetClosed2017-05-30

Actions
Actions #1

Updated by Riccardo De Contardi almost 7 years ago

  • Target version deleted (8 LTS)
Actions #2

Updated by Marcelo Vetter almost 7 years ago

  • % Done changed from 0 to 70
  • Complexity changed from no-brainer to medium

So after days and days and days!!! of search, trials, and errors, I finally found a way to enable the auto populated parameter of a link according to their type for and outside rte_ckeditor or even outside rtehtmlarea. It's not exactly what I wanted but is almost there!

Adding this to my Page TSConfig solved part of the problem:

TCEMAIN.linkHandler {
    # I don't want to load the folder link handler so I reset it.
    folder >
    # Leaving page type empty on purpose.
    page {
    }
    file {
        addParams = onclick="jumpToUrl('?act=file&linkAttributes[target]=_blank&linkAttributes[title]=Opens or downloads file in new window&linkAttributes[class]=download&linkAttributes[params]=');return false;" 
    }
    url {
        addParams = onclick="jumpToUrl('?act=url&linkAttributes[target]=_blank&linkAttributes[title]=Opens external link in new window&linkAttributes[class]=externalLink&linkAttributes[params]=');return false;" 
    }
    mail {
        addParams = onclick="jumpToUrl('?act=mail&linkAttributes[title]=Opens email manager to send an email&linkAttributes[class]=mail&linkAttributes[params]=');return false;" 
    }
}

I didn't configure anything for 'page' because if it's populated and I click on File, External Url, Email, or any other custom link handler, the attributes are passed along from the Page link handler, which defeats the purpose of the pre-populated parameters for each link handler type.

The only remaining issue is if I click for example on External URL, the target will be "_blank", title will be "Opens external link in new window" and class will be "externalLink". So far so good. Then if you click to link a File or even to link an internal Page, those parameters that pre-loaded for External URL will be passed along, which I think it shouldn't happen. Since I'm trying to pre-populate each link type, why would I want to keep the attribute of a previous link type? This might be just a matter of opinion, but I would like to have the option for force pre-populated parameters for each link type. Maybe I'm just missing a small config to achieve this behavior.

This answer was also posted here: http://stackoverflow.com/questions/43596767/how-to-define-custom-class-title-and-target-in-link-browser-for-content-elemen/43643585#43643585

Actions #3

Updated by Frans Saris over 6 years ago

  • Tracker changed from Feature to Bug
  • Status changed from New to Closed
  • TYPO3 Version set to 8

Duplicate of #81381

Actions #4

Updated by Frans Saris over 6 years ago

  • Is duplicate of Bug #81381: RTE TSConfig is lost when using own CKEditor preset added
Actions #5

Updated by Thomas Anders over 3 years ago

How can you achive this in TYPO3 v10?

I used the addParams() example. Due to the deprecation of jumpToUrl() it throws only an error and uses the default behaviour instead.

So I tried to use window.location.href as told here:
https://forge.typo3.org/projects/typo3cms-core/repository/revisions/04ea328d3f48e680317262f574e3a64abfbc93b8/entry/typo3/sysext/core/Documentation/Changelog/master/Deprecation-89033-JumpToUrl.rst
This loads the full backend inside the modal-box instead of the wizard-page.

Is there currently a working solution or workaround for v10?

Actions

Also available in: Atom PDF