Content management system 类型3上的链接处理程序挂钩8
对于TYPO3 8.7,是否有任何钩子可以使用新的LinkHandler处理链接 在旧的LinkHandler扩展上,可以定义一个钩子来处理我们想要的链接。Content management system 类型3上的链接处理程序挂钩8,content-management-system,typo3,typo3-8.7.x,Content Management System,Typo3,Typo3 8.7.x,对于TYPO3 8.7,是否有任何钩子可以使用新的LinkHandler处理链接 在旧的LinkHandler扩展上,可以定义一个钩子来处理我们想要的链接。 我需要根据一些规则覆盖typolink的参数。在我的分机上有这样做的方法吗?有多个连接点 打字链接后处理 您可以在打印链接呈现之前,钩住打印链接后处理,修改打印链接本身 为此,首先在ext_tables/ext_localconf中注册自定义类: $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tsli
我需要根据一些规则覆盖typolink的参数。在我的分机上有这样做的方法吗?有多个连接点 打字链接后处理
您可以在打印链接呈现之前,钩住打印链接后处理,修改打印链接本身 为此,首先在ext_tables/ext_localconf中注册自定义类:
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['typoLink_PostProc'][] = 'Vendor\\Name\\Service\\TypoLinkProcessingService->postProcessTypoLink';
然后,在您的TypoLinkProcessingService
类中(当然,您可以选择您的名字),您可以在自己的方法中处理它。出于可视化目的,在本例中,如果URL是指向youtube视频的链接,我将更改URL,以便在结尾关闭“相关视频”,并修改youtube播放器内控件使用的颜色
public function postProcessTypoLink(&$parameters, ContentObjectRenderer &$parentObject)
{
if (isset($parameters['finalTagParts']['url'])) {
$urlParts = parse_url($parameters['finalTagParts']['url']);
if (stristr($urlParts['host'], 'youtube.com') !== false && stristr($urlParts['path'], 'watch') !== false) {
$parameters['finalTag'] = str_replace(
'"' . htmlspecialchars($parameters['finalTagParts']['url']) . '"',
'"' . htmlspecialchars($parameters['finalTagParts']['url'] . '&rel=0&color=ffffff') . '"',
$parameters['finalTag']
);
}
}
}
typlink UserFunc
另一个选项是使用
userFunc
并调整链接
为此,您可以将linkhandler配置(PageTS)配置为在typolink
中提供userFunc
。根据需要添加打字脚本,以便稍后获取配置的数据
config.recordLinks {
tx_myest {
typolink {
userFunc = Vendor\Name\UserFunc\TypolinkUserFunc->parseLinkHandlerTypolink
userFunc {
newsUid = TEXT
newsUid.data = field:uid
newsClass = TEXT
newsClass.data = parameters:class
defaultDetailPid = 53
}
}
}
}
在parseLinkHandlerTypolink
方法中,您可以访问配置的属性并根据需要进行调整:
class TypolinkUserFunc
{
/**
* @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
* @inject
*/
public $cObj;
/**
* Add a method description here
*
* @param array $content
* @param array $configuration
* @return string
*/
public function parseNewsLinkHandlerTypolink(array $content, array $configuration)
{
if (!$configuration['newsUid']) {
return;
}
$params = $this->cObj->cObjGetSingle($configuration['newsClass'], $configuration['newsClass.']);
$newsUid = (int)$this->cObj->cObjGetSingle($configuration['newsUid'], $configuration['newsUid.']);
// ... your code goes here ...
$url = $this->cObj->typolink('', $typolink);
return '<a href="' . $url . '" ' . $attributes . '>';
}
}
类TypolinkUserFunc
{
/**
*@var\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*@注入
*/
公共财政司司长;
/**
*在此处添加方法说明
*
*@param数组$content
*@param数组$configuration
*@返回字符串
*/
公共函数parseNewsLinkHandlerTypolink(数组$content,数组$configuration)
{
如果(!$configuration['newsUid']){
返回;
}
$params=$this->cObj->cObjGetSingle($configuration['newclass'],$configuration['newclass']);
$newsUid=(int)$this->cObj->cObjGetSingle($configuration['newsUid'],$configuration['newsUid']);
//…你的代码在这里。。。
$url=$this->cObj->typolink(“”,$typolink);
返回'