Skip to content

Commit 4c81459

Browse files
committed
Fix CSS overrides & user.css not loading on error or offline pages
1 parent 1ad7182 commit 4c81459

File tree

3 files changed

+36
-12
lines changed

3 files changed

+36
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## WIP
44
- Fix image resize/optimiser
5+
- Fix CSS overrides not loading on error or offline pages
6+
- Fix `user.css` not loading on error or offline pages
57

68
## 1.1.0
79
- Add support for user.css

error.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,28 @@
2020
$menu = $app->getMenu()->getActive();
2121
$pageclass = $menu !== null ? $menu->getParams()->get('pageclass_sfx', '') : '';
2222
$themeSwitcher = (boolean)$this->params->get('theme-switcher', 1);
23+
$fontAwesome = (boolean)$this->params->get('font-awesome-thats-actually-rather-shit', 1);
2324

2425
// Template params
2526
if ($themeSwitcher)
2627
{
2728
HTMLHelper::_('stylesheet', 'switch.css', ['version' => 'auto', 'relative' => true]);
2829
}
29-
HTMLHelper::_('script', 'switch.min.js', ['version' => 'auto', 'relative' => true], ['type' => 'module']);
3030

3131
// Fetch CSS
32-
$css = file_get_contents(__DIR__ . '/css/template.css');
32+
HTMLHelper::_('stylesheet', 'template.css', ['version' => 'auto', 'relative' => true]);
33+
HTMLHelper::_('stylesheet', 'custom-variables.css', ['version' => 'auto', 'relative' => true]);
34+
HTMLHelper::_('stylesheet', 'user.css', ['version' => 'auto', 'relative' => true]);
35+
36+
// Font Awesome
37+
if ($fontAwesome)
38+
{
39+
HTMLHelper::_('stylesheet', 'fontawesome.css', ['version' => 'auto', 'relative' => true]);
40+
}
41+
42+
// Load switcher JS
43+
// This should be loaded even if the themeSwitcher is disabled, so that the system preference will still dictate the theme
44+
HTMLHelper::_('script', 'switch.min.js', ['version' => 'auto', 'relative' => true], ['type' => 'module']);
3345

3446
// Logo file or site title param
3547
$logo = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 508.928 508.928" height="50"><path fill="hsl(210, 100%, 50%)" d="M403.712 201.04H256.288L329.792 0 105.216 307.888H252.64l-73.504 201.04z"/></svg>';
@@ -53,7 +65,8 @@
5365
<html lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
5466
<head>
5567
<jdoc:include type="metas" />
56-
<style><?php echo $css; ?></style>
68+
<jdoc:include type="styles" />
69+
<jdoc:include type="scripts" />
5770
</head>
5871

5972
<body class="site-grid site <?php echo $pageclass; ?>">
@@ -129,8 +142,5 @@
129142
<?php endif; ?>
130143

131144
<jdoc:include type="modules" name="debug" style="none" />
132-
133-
<jdoc:include type="styles" />
134-
<jdoc:include type="scripts" />
135145
</body>
136146
</html>

offline.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,28 @@
2323

2424
// Template params
2525
$themeSwitcher = (boolean)$this->params->get('theme-switcher', 1);
26+
$fontAwesome = (boolean)$this->params->get('font-awesome-thats-actually-rather-shit', 1);
27+
28+
// Load switcher CSS
2629
if ($themeSwitcher)
2730
{
2831
HTMLHelper::_('stylesheet', 'switch.css', ['version' => 'auto', 'relative' => true]);
2932
}
30-
HTMLHelper::_('script', 'switch.min.js', ['version' => 'auto', 'relative' => true], ['type' => 'module']);
3133

3234
// Fetch CSS
33-
$css = file_get_contents(__DIR__ . '/css/template.css');
35+
HTMLHelper::_('stylesheet', 'template.css', ['version' => 'auto', 'relative' => true]);
36+
HTMLHelper::_('stylesheet', 'custom-variables.css', ['version' => 'auto', 'relative' => true]);
37+
HTMLHelper::_('stylesheet', 'user.css', ['version' => 'auto', 'relative' => true]);
38+
39+
// Font Awesome
40+
if ($fontAwesome)
41+
{
42+
HTMLHelper::_('stylesheet', 'fontawesome.css', ['version' => 'auto', 'relative' => true]);
43+
}
44+
45+
// Load switcher JS
46+
// This should be loaded even if the themeSwitcher is disabled, so that the system preference will still dictate the theme
47+
HTMLHelper::_('script', 'switch.min.js', ['version' => 'auto', 'relative' => true], ['type' => 'module']);
3448

3549
// Logo file or site title param
3650
$sitename = htmlspecialchars($app->get('sitename'), ENT_QUOTES, 'UTF-8');
@@ -54,7 +68,8 @@
5468
<head>
5569
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5670
<jdoc:include type="metas" />
57-
<style><?php echo $css; ?></style>
71+
<jdoc:include type="styles" />
72+
<jdoc:include type="scripts" />
5873
</head>
5974
<body class="site-grid site">
6075
<div class="grid-child container-header full-width">
@@ -155,8 +170,5 @@ class="btn btn-secondary btn-block mt-4 <?php echo $button['class'] ?? '' ?>"
155170
</div>
156171
</div>
157172
</div>
158-
159-
<jdoc:include type="styles" />
160-
<jdoc:include type="scripts" />
161173
</body>
162174
</html>

0 commit comments

Comments
 (0)