TYPO3 RTE-Link 链接页面的 id 作为数据属性或 rel 标签?

TYPO3 RTE-Link with id of linked page as data-atribute or rel-tag?

我正在尝试将 linked 页面的特殊 ID 作为 rel-attribute 添加到 RTE 的每个 a-Tag。 目前,rel 部分包含在 link 中,但在 "page:uid" 中它插入实际页面 ID 而不是 linked 页面的 ID。

lib.parseFunc_RTE.tags.link {
  typolink.parameter.append < lib.parseFunc.tags.link.typolink.parameter.append
  typolink.ATagParams = rel={page:uid}
  wrap < lib.parseFunc.tags.link.newWrap
}

例如: 站点 "Contact" 的 ID 号为 210,但目前,我在 ID = 11 的 "start" 页面上。 现在我在 "start" 到 "Contacts" 页面有一个 textlink。 HTML 部分如下所示:

<a href="contacts/" rel="11">contact</a>

但应该是这样的

<a href="contacts/" rel="210">contact</a>

或者像这样更好(具有特殊数据属性)

<a href="contacts/" data-relation="210">contact</a>

我怎样才能得到这个? 非常感谢。

你尝试做的事情在 TypoScript 中有点棘手,但并非不可能。您必须处理伪 <link> 标记的参数,它看起来像 162 - some-class ... - 162 是本例中的页面 ID。

打字稿

# Simulating some content
page = PAGE
page.10 = TEXT
page.10.value (
  <link 162 - some-class>Some page</link>
)

page.10.parseFunc =< lib.parseFunc_RTE

# Adjusting parsing instructions for pseudo links
lib.parseFunc_RTE {
  tags.link {
    typolink.ATagParams.append = TEXT
    typolink.ATagParams.append {
      stdWrap {
        # having all link settings "162 - some-class ..."
        data = parameters:allParams
        # split by whitespace
        split.token.char = 32
        # use first item
        split.returnKey = 0
        # enforce integer values
        intval = 1
      }
      noTrimWrap = | data-relation="|"|
    }
  }
}

生成的标记

<p class="bodytext">
  <a href="/tests/some-page" class="some-class" data-relation="162">Some page</a>
</p>