我有这样的打字稿:
lib.rccProcessTexts = CONTENT
lib.rccProcessTexts {
table = tt_content
select {
pidInList = {$rcc.ids.pidRccProcessTexts}
}
renderObj = COA
renderObj {
10 = TEXT
# The field tt_content.bodytext holds the content text.
10.stdWrap.field = bodytext
10.stdWrap.wrap = <div data-phase-id="{field:colPos}">|</div>
10.insertData = 1
}
wrap = <div class="hidden" data-process-texts>|</div>
}
所以这个 Typoscript 从 tt_content 获取内容。任何拼写错误链接 (t3://...
) 都不会被真实链接(如 https://www.example.com/go/to/page
)取代。
如何让TYPO3创建真实链接?
你有2种可能性。
就是给TEXT对象加上这个parseFunc:
10.stdWrap.parseFunc < lib.parseFunc_RTE
这将导致文本像往常一样被解析。
所以最后:
...
...
renderObj = COA
renderObj {
10 = TEXT
# The field tt_content.bodytext holds the content text.
10.stdWrap.field = bodytext
10.stdWrap.wrap = <div data-phase-id="{field:colPos}">|</div>
10.insertData = 1
10.stdWrap.parseFunc < lib.parseFunc_RTE
}
...
10.stdWrap.parseFunc.userFunc = My\Way\To\MyClass.php->doSomething()
然后只需将带有 doSomething() 的 Class.php 添加到 Classes/UserFunc 文件夹中。课堂是这样的:
<?php
namespace My\Way\To;
class MyClass
{
/**
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
public $cObj;
/**
*
* @param string When custom methods are used for data processing (like in stdWrap functions), the $content variable will hold the value to be processed. When methods are meant to just return some generated content (like in USER and USER_INT objects), this variable is empty.
* @param array TypoScript properties passed to this method.
* @return string The input string reversed. If the TypoScript property "uppercase" was set, it will also be in uppercase. May also be linked.
*/
public function doSomething(string $content, array $conf): string
{
// Have fun
}
}