Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR for multiple flavour and child-theme related issues #792

Merged
merged 6 commits into from
Jan 2, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Child theme support: Fully replicate Boost Union's extra SCSS if a Bo…
…ost Union Child theme is the current theme, resolves #718, resolves theme_boost_union_child/#5.
abias committed Jan 1, 2025
commit 64f70858fb46f13d1a7b6a22acc72c82b1d77cf3
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@ Changes

### Unreleased

* 2024-12-31 - Child theme support: Fully replicate Boost Union's extra SCSS if a Boost Union Child theme is the current theme, resolves #718, resolves theme_boost_union_child/#5.
* 2024-12-31 - Bugfix / Child theme support: The theme_boost_union_get_pre_scss() and theme_boost_union_get_extra_scss() function used $theme->settings although they should not do that anymore, resolves #791
* 2024-12-31 - Tests: Increase the test coverage for the background image setting, helps to resolve theme_boost_union_child/#5
* 2024-12-31 - Bugfix: In flavours, not setting the brand color / bootstrap colors in a flavour did not result in the global brand color / bootstrap colors being served properly, resolves #790.
16 changes: 15 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
@@ -208,6 +208,13 @@ function theme_boost_union_get_pre_scss($theme) {
// We have to accept this fact here and must not copy the code from theme_boost_get_pre_scss into this function.
// Instead, we must only add additionally CSS code which is based on any Boost Union-only functionality.

// But, well, there is one exception: Boost Union Child themes.
// Due to the described call chain, Boost Union Child won't get all the necessary extra SCSS.
// Thus, we fetch Boost's extra SCSS if the current theme is not Union itself (i.e. a Boost Union Child theme is active).
if (theme_boost_union_is_active_childtheme() == true) {
$scss .= theme_boost_get_pre_scss(\core\output\theme_config::load('boost_union'));
}

// Include pre.scss from Boost Union.
$scss .= file_get_contents($CFG->dirroot . '/theme/boost_union/scss/boost_union/pre.scss');

@@ -408,7 +415,14 @@ function theme_boost_union_get_extra_scss($theme) {
// We have to accept this fact here and must not copy the code from theme_boost_get_extra_scss into this function.
// Instead, we must only add additionally CSS code which is based on any Boost Union-only functionality.

// In contrast to Boost core, Boost Union should add the login page background to the body element as well.
// But, well, there is one exception: Boost Union Child themes.
// Due to the described call chain, Boost Union Child won't get all the necessary extra SCSS.
// Thus, we fetch Boost's extra SCSS if the current theme is not Union itself (i.e. a Boost Union Child theme is active).
if (theme_boost_union_is_active_childtheme() == true) {
$content .= theme_boost_get_extra_scss(\core\output\theme_config::load('boost_union'));
}

// Now, in contrast to Boost core, Boost Union should add the login page background to the body element as well.
// Thus, check if a login background image is set.
$loginbackgroundimagepresent = get_config('theme_boost_union', 'loginbackgroundimage');
if (!empty($loginbackgroundimagepresent)) {
16 changes: 16 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
@@ -2522,3 +2522,19 @@ function theme_boost_union_is_active_theme() {
return false;
}
}

/**
* Helper function to check if a child theme of Boost Union (and _not_ Boost Union itself) is active.
* This is needed at multiple locations to improve child theme support in Boost Union already.
*
* @return bool
*/
function theme_boost_union_is_active_childtheme() {
global $PAGE;

if ($PAGE->theme->name != 'boost_union') {
return true;
} else {
return false;
}
}