Bug #82486
closedIncludeJS* / includeCSS* (including compression / concatenation) ignoring absRefPrefix
0%
Description
The includeJS and includeCSS functions in typoscript are ignoring the given absRefPrefix.
I tested this on a fresh installation of TYPO3 8.7.6 with the following typoscript code:
config { absRefPrefix = /foo/ compressJs = 1 } page = PAGE page { 10 = TEXT 10.value = HELLO WORLD! # setting a link to test if absRefPrefix works 10.typolink.parameter = 1 includeJSLibs.js1 = fileadmin/js1.js includeJSLibs.js2 = fileadmin/js2.js includeCSS.css1 = fileadmin/css1.css includeCSSLibs.css1 = fileadmin/css1.css }
This gives me the following html output on the generated page:
<link rel="stylesheet" type="text/css" href="/fileadmin/css1.css?1505384618" media="all">
<link rel="stylesheet" type="text/css" href="/fileadmin/css1.css?1505384618" media="all">
<script src="/typo3temp/assets/compressed/js1-5130fdbc94c8b9e6f1802cab56df2b78.js?1505384940" type="text/javascript"></script>
<script src="/typo3temp/assets/compressed/js2-2a2ef88a17be994adbe3c851da68f8fe.js?1505384940" type="text/javascript"></script>
The sources do get a prefix - but it's "/" instead of the declared absRefPrefix "/foo/".
The test link on the other hand is generated correctly:
<a href="/foo/index.php?id=1">HELLO WORLD!</a>
Updated by Rémy DANIEL about 7 years ago
- Related to Bug #77722: absRefPrefix is not applied everywhere added
Updated by Klaus Moser almost 7 years ago
Same issue here. I think this is caused by TYPO3\CMS\Core\Utility\PathUtility:getAbsoluteWebPath().
The method makes a path absolute by adding GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') and ignores the configured absRefPrefix.
I don't know if there is a better way to get the configured absRefPrefix, but this could fix the issue:
if (isset($GLOBALS['TSFE']->config['config']['absRefPrefix']) && !empty($GLOBALS['TSFE']->config['config']['absRefPrefix'])) {
$targetPath = rtrim($GLOBALS['TSFE']->config['config']['absRefPrefix'], '/') . '/' . $targetPath;
} else {
$targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
}
Updated by Adrien Jacob almost 7 years ago
Thanks a lot for the suggested fix, it did the job for me...
Updated by Riccardo De Contardi almost 7 years ago
- Related to Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9 added
Updated by Markus Klein over 6 years ago
- Is duplicate of Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9 added
Updated by Markus Klein over 6 years ago
- Related to deleted (Bug #83630: Config.absRefPrefix not working anymore for includeCSS, includeJs, includeJSLibs, includeCSSLibs after update to 8.7.9)
Updated by Markus Klein over 6 years ago
- Status changed from New to Closed
Closing this as duplicate.