4

先决条件

[x] 你能在 TYPO3 8.7 LTS 上重现这个问题吗?

[x] 您是否 [执行粗略搜索] 以查看您的错误或增强功能是否已被报告?-是的

描述

如何在 Typo3 8 LTS 的任何元素链接(通常是元素标题和图像)和 rte_ckeditor 中为链接浏览器配置默认链接目标、类和标题?我花了几个小时尝试配置它,但没有成功,也没有文档。如下图所示,这些字段是空的。

在此处输入图像描述 在此处输入图像描述

重现问题的步骤

  1. 创建可以链接标题或图像的任何元素。
  2. 点击打开链接浏览器
  3. 任何类型的链接(页面、文件、文件夹、外部 URL、电子邮件)的选项都是空的。

预期行为:如果它们为空,我想为每种类型的链接定义默认类、链接目标和标题。例如外部 URL,如果之前未配置链接,我想自动填充 target="_blank"、class "external-link"、title="Link to External Website"。基本上对于任何新链接,我只想让它自动填充我的自定义值而不是空值。

这曾经仅在以前的 Typo3 版本上适用于 rtehtmlarea,但我无法在 Typo3 8 LTS 和 ckeditor 上设置此选项系统范围。

过去仅适用于 rtehtmlarea 的 PageTS 是这样的:

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 =
        }
    }
}

我希望这适用于新的 rte_ckeditor 以及我可以使用链接浏览器链接的任何元素选项。

4

5 回答 5

5

TYPO3 8.7.8 中存在一个错误(仅限) - 请参阅:https ://forge.typo3.org/issues/82865

[编辑] classesAnchor 的东西只在版本 8.7.5 到 8.7.7 中有效,并且有望在 8.7.9 中再次工作

但正确的答案应该是(就像 Ghanshyam Bhava 在他的评论中指出的那样)切换到 YAML 配置。

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'

RTE 之外的其他字段的链接浏览器应该可以通过 TCA-Overrides 实现。

于 2017-12-06T09:26:02.200 回答
3

所以过了几天又几天!!!经过搜索、试验和错误,我终于找到了一种方法,可以根据链接的类型在外部rte_ckeditor甚至外部启用自动填充参数rtehtmlarea。这不完全是我想要的,但几乎就在那里!

将此添加到我的 Page TSConfig 解决了部分问题:

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;"
    }
}

我没有配置任何内容,page因为如果它已填充并且我单击文件、外部 URL、电子邮件或任何其他自定义链接处理程序,属性将从页面链接处理程序传递,这违背了预填充参数的目的对于每个链接处理程序类型。

唯一剩下的问题是,如果我单击例如External URL,目标将是"_blank",标题将是"Opens external link in new window",类将是"externalLink"。到目前为止,一切都很好。然后,如果您单击链接 aFile甚至链接 internal Page,那些为 External URL 预加载的参数将被传递,我认为这不应该发生。既然我试图预先填充每个链接类型,我为什么要保留前一个链接类型的属性?这可能只是一个见仁见智的问题,但我希望可以选择为每种链接类型强制预填充参数。也许我只是缺少一个小配置来实现这种行为。

于 2017-04-26T20:04:39.653 回答
2

这是解决方案,

RTE.default {

     # This will provide only basic tool in the text RTE
     preset = default

     ## Bootstrap CSS
     contentCSS {
         20 = fileadmin/Resources/Public/Bootstrap/css/bootstrap.css
     }


     classesAnchor {
        url {
            class = externalLink
            type = url
            titleText = Opens external link in new window
            target = _blank
            image =
         }

        page {
            class = internalLink
            type = page
            titleText =  Opens internal link in this window
            target = _top
            image =
        }

        file {
            class = download
            type = file
            titleText = external file
            target = _blank
            image =
        }

        folder {
            class = folder
            type = folder
            titleText = folder file
            target = _blank
            image =
        }

        mail {
            class = mail
            type = mail
            titleText = Email Address
            image =
        }
    }

    buttons.link{
        page.properties.class.default = internalLink

        url.properties.class.default = externalLink

        folder.properties.class.default = folder

        file.properties.class.default = download

        mail.properties.class.default = mail

        properties.class.allowedClasses = internalLink,externalLink,folder,mail,download
    }
}

看看这个,我也添加了默认链接标题以及它的目标。你可以看到我的后端的输出:

在此处输入图像描述

于 2017-04-25T04:26:15.033 回答
0

I have tested this solution in TYPO3 9 with ckeditor in my yaml configuration file to load my own defaults. It works fine except the default settings don't work as expected. The titleText, is currently overwritten by the last title of the same type. e.g. for the type 'page' the title 'Opens internal link in new window' is loaded instead of 'Opens internal link in this window'.

buttons:
  link:
    relAttribute:
      enabled: true
    page:
      properties:
        class:
          default: internal-link
    url:
      properties:
        class:
          default: external-link-new-window
    folder:
      properties:
        class:
          default: folder
    file:
      properties:
        class:
          default: download
    mail:
      properties:
        class:
          default: mail
    properties:
      class:
        allowedClasses: 'internal-link,internal-link-new-window,download,external-link,external-link-new-window,mail'

#Classes config
classesAnchor:
  internalLink:
    class: 'internal-link'
    type: 'page'
    titleText: 'Opens internal link in this window'
  internalLinkNewWindow:
    class: 'internal-link-new-window'
    type: 'page'
    target: '_blank'
    titleText: 'Opens internal link in new window'
  download:
    class: 'download'
    type: 'file'
    target: '_blank'
    titleText: 'Download file'
  externalLink:
    class: 'external-link'
    type: 'url'
    titleText: 'Opens External link in this window'
  externalLinkNewWindow:
    class: 'external-link-new-window'
    type: 'url'
    target: '_blank'
    titleText: 'Opens External link in new window'
  linkMail:
    class: 'mail'
    type: 'mail'
    titleText: 'Email Address'
于 2020-01-24T15:05:27.933 回答
0

要在 yaml 中配置默认​​类,您必须在 .yaml 文件中添加这样的默认类:

classesAnchor:
    page:
        class: 'link-page'
        type: 'page'
        target: '_top'
    file:
        class: 'link-file'
        type: 'file'
        target: '_blank'
        titleText: 'Download'
    url:
        class: 'link-external'
        type: 'url'
        target: '_blank'
    mail:
        class: 'link-mail'
        type: 'mail'
        titleText: 'Send email'


buttons:
    link:
        properties:
            class:
                allowedClasses: 'link-page, link-file, link-external, link-mail'
        page:
            properties:
                class:
                    default: 'link-page'
        file:
            properties:
                class:
                    default: 'link-file'
        url:
            properties:
                class:
                    default: 'link-external'
        mail:
            properties:
                class:
                    default: 'link-mail'
于 2020-09-01T11:32:07.330 回答