Skip to content

Commit

Permalink
[FEATURE] Allow forceOnTop for JS/CSS files
Browse files Browse the repository at this point in the history
Also fix default values for rel and media
And add option for compress

Resolves: #570
Release: 12.0.1
  • Loading branch information
opi99 committed Jun 3, 2024
1 parent 8da0f5f commit 1195c92
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Classes/Controller/Frontend/PageBasicsHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,20 @@ public static function processConfiguration(TemplateConfiguration $templateConfi
// CSS
if (isset($headerConfiguration['css']) && is_array($headerConfiguration['css'])) {
foreach ($headerConfiguration['css'] as $cssConfiguration) {
$pageRenderer->addCssFile($cssConfiguration['href'], $cssConfiguration['rel'], $cssConfiguration['media']);
$jsConfiguration['rel'] = ($jsConfiguration['rel'] ?? 'stylesheet');
$jsConfiguration['media'] = ($jsConfiguration['media'] ?? 'all');
$cssConfiguration['compress'] = (bool) ($cssConfiguration['compress'] ?? true);
$cssConfiguration['forceonTop'] = (bool) ($cssConfiguration['forceonTop'] ?? false);
$pageRenderer->addCssFile($cssConfiguration['href'], $cssConfiguration['rel'], $cssConfiguration['media'], '', $cssConfiguration['compress'], $cssConfiguration['forceonTop']);
}
}
// Javascript
if (isset($headerConfiguration['javascript']) && is_array($headerConfiguration['javascript'])) {
foreach ($headerConfiguration['javascript'] as $jsConfiguration) {
$pageRenderer->addJsFile($jsConfiguration['src']);
$jsConfiguration['type'] = ($jsConfiguration['type'] ?? 'text/javascript');
$jsConfiguration['compress'] = (bool) ($jsConfiguration['compress'] ?? true);
$jsConfiguration['forceonTop'] = (bool) ($jsConfiguration['forceonTop'] ?? false);
$pageRenderer->addJsFile($jsConfiguration['src'], $jsConfiguration['type'], $jsConfiguration['compress'], $jsConfiguration['forceonTop']);
}
}

Expand Down

0 comments on commit 1195c92

Please sign in to comment.