Skip to content

Commit

Permalink
Feature: Make the course content column width configurable, helps to r…
Browse files Browse the repository at this point in the history
…esolve #18.

With this patch, admins can override Moodle's default content width without manual SCSS modifications.
  • Loading branch information
abias committed Jul 7, 2022
1 parent ba6e52c commit 04e4ed6
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changes

### Unreleased

* 2022-07-07 - Feature: Make the course content column width configurable, helps to resolve #18.
* 2022-07-06 - Feature: Built-in imprint, solves #32
* 2022-07-05 - Feature: Configurable favicon, solves #34
* 2022-07-05 - Feature: Allow non-admins to edit theme settings, solves #28
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ This setting is already available in the Moodle core theme Boost. For more infor

In this tab there are the following settings:

#### Layout

##### Course content max width

With this setting, you can override Moodle's default content width without manual SCSS modifications.

#### Navigation

##### Back to top button
Expand Down
3 changes: 3 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@

// Settings: Page tab.
$string['pagetab'] = 'Page';
$string['layoutheading'] = 'Layout';
$string['coursecontentmaxwidthsetting'] = 'Course content max width';
$string['coursecontentmaxwidthsetting_desc'] = 'With this setting, you can override Moodle\'s default content width without manual SCSS modifications. By default, Moodle uses a course content max width of 830px. You can enter other pixel-based values like 1200px, but you can also enter a percentage-based value like 100%.';
$string['navigationheading'] = 'Navigation';
$string['backtotop'] = 'Back to top';
$string['backtotopbuttonsetting'] = 'Back to top button';
Expand Down
6 changes: 6 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ function theme_boost_union_get_pre_scss($theme) {
}, (array) $targets);
}

// Overwrite Boost core SCSS variables which need units and thus couldn't be added to $configurable above.
// Set variables which are influenced by the coursecontentmaxwidth setting.
if (isset($theme->settings->coursecontentmaxwidth)) {
$scss .= '$course-content-maxwidth: '.$theme->settings->coursecontentmaxwidth.";\n";
}

// Prepend pre-scss.
if (!empty($theme->settings->scsspre)) {
$scss .= $theme->settings->scsspre;
Expand Down
17 changes: 17 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,23 @@
// Create page tab.
$page = new admin_settingpage('theme_boost_union_page', get_string('pagetab', 'theme_boost_union', null, true));

// Create layout heading.
$name = 'theme_boost_union/layoutheading';
$title = get_string('layoutheading', 'theme_boost_union', null, true);
$setting = new admin_setting_heading($name, $title, null);
$page->add($setting);

// Setting: Course content max width.
$name = 'theme_boost_union/coursecontentmaxwidth';
$title = get_string('coursecontentmaxwidthsetting', 'theme_boost_union', null, true);
$description = get_string('coursecontentmaxwidthsetting_desc', 'theme_boost_union', null, true);
$default = '830px';
// Regular expression for checking if the value is a percent number (from 0% to 100%) or a pixel number (with 3 or 4 digits).
$regex = '/^((\d{1,2}|100)%)|(\d{3,4}px)$/';
$setting = new admin_setting_configtext($name, $title, $description, $default, $regex, 7);
$setting->set_updatedcallback('theme_reset_all_caches');
$page->add($setting);

// Create navigation heading.
$name = 'theme_boost_union/navigationheading';
$title = get_string('navigationheading', 'theme_boost_union', null, true);
Expand Down
3 changes: 3 additions & 0 deletions tests/behat/theme_boost_union_page_settings.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Feature: Configuring the theme_boost_union plugin for the "Page" tab
| teacher1 | C1 | editingteacher |
| student1 | C1 | student |

# Unfortunately, this can't be tested with Behat yet
# Scenario: Overwrite the course content max width setting

@javascript
Scenario: Enable "Back to top button"
Given the following config values are set as admin:
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'theme_boost_union';
$plugin->version = 2022031709;
$plugin->version = 2022031710;
$plugin->release = 'v4.0-r1';
$plugin->requires = 2022041900;
$plugin->supported = [400, 400];
Expand Down

0 comments on commit 04e4ed6

Please sign in to comment.