最佳答案
在TYPO3 v9中,您必须在每种模式下执行以下操作
原文链接:https://www.f2er.com/css/530711.html的CSS
$GLOBALS['TBE_STYLES']['skins']['nameOfContentElement'] = array();
$GLOBALS['TBE_STYLES']['skins']['nameOfContentElement']['name'] = 'My Awesome Name';
$GLOBALS['TBE_STYLES']['skins']['nameOfContentElement']['stylesheetDirectories'] = array(
'visual' => 'yourextension/Resources/Public/Css/Backend','theme' => 'yourextension/Resources/Public/Css/Monokai'
);
此处的路径(CSS)是目录,因此它将读取指向的目录中的所有文件.
JS
$renderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRender
$renderer->addJsFile('yourextension/Resources/Public/JavaScript/Backend.js','text/javascript',false,'',true,'|','');
$renderer->addJsFile('yourextension/Resources/Public/JavaScript/another.js','');
参数:
addJsFile(
$file,$type = 'text/javascript'
$compress = true,$forceOnTop = false,$allWrap = '',$excludeFromConcatenation = false,$splitChar = '|',$async = false,$integrity = ''
);
在大文件中,加载可能会有一些问题,但是如果有人可以确认,我将非常感激.
附加信息:
如果要使用TYPO3的jQuery(强烈建议使用jQuery,以避免发生冲突),则还应使用以下内容:
require(["jquery"],function($) {
//your awesome function
}
您也可以使用条件来确保它在后端加载:
if (TYPO3_MODE === 'BE') {
$renderer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Page\PageRender
...
}