diff --git a/CHANGES.md b/CHANGES.md
index 7ff0373889e..17a25085cbe 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -6,6 +6,7 @@ Changes
### Unreleased
+* 2024-02-22 - Feature: Allow the admin to change the link behind the logo in the navbar, resolves #565.
* 2024-02-22 - Feature: Allow administrators to change the order of login items on the login page without using CSS or touching the mustache template, resolves #504.
### v4.3-r7
diff --git a/README.md b/README.md
index 97636081661..3fe4763be4c 100644
--- a/README.md
+++ b/README.md
@@ -311,6 +311,10 @@ In this tab there are the following settings:
With this setting, you can hide one or multiple nodes from the primary navigation.
+###### Alternative logo link URL
+
+With this setting, you can set an alternative link URL which will be used as link on the logo in the navigation bar. You can use this setting to, for example, link to your organization's website instead of the Moodle frontpage to maintain a homogeneous navigation bar throughout all of your organization's systems.
+
##### User menu
###### Add preferred language link to language menu
diff --git a/lang/en/theme_boost_union.php b/lang/en/theme_boost_union.php
index a586d9a64b5..200640f7bd7 100644
--- a/lang/en/theme_boost_union.php
+++ b/lang/en/theme_boost_union.php
@@ -388,6 +388,10 @@
$string['hidenodesprimarynavigationsetting'] = 'Hide nodes in primary navigation';
$string['hidenodesprimarynavigationsetting_desc'] = 'With this setting, you can hide one or multiple nodes from the primary navigation.
Please note: Here, you can just remove navigation nodes. But if you want to add custom navigation nodes, please consider using Boost Union\'s smart menu functionality.';
+// ... ... Settings: Alternative logo link URL.
+$string['alternativelogolinkurlsetting'] = 'Alternative logo link URL';
+$string['alternativelogolinkurlsetting_desc'] = 'With this setting, you can set an alternative link URL which will be used as link on the logo in the navigation bar. You can use this setting to, for example, link to your organization\'s website instead of the Moodle frontpage to maintain a homogeneous navigation bar throughout all of your organization\'s systems.';
+
// ... Section: User menu.
$string['usermenuheading'] = 'User menu';
// ... ... Settings: Add preferred language link to language menu.
diff --git a/layout/includes/navbar.php b/layout/includes/navbar.php
index 0112ba389a2..65d9b55fce1 100644
--- a/layout/includes/navbar.php
+++ b/layout/includes/navbar.php
@@ -24,9 +24,8 @@
defined('MOODLE_INTERNAL') || die();
-$navbarcolorsetting = get_config('theme_boost_union', 'navbarcolor');
-
// Compose the navbar color classes based on the navbarcolor setting.
+$navbarcolorsetting = get_config('theme_boost_union', 'navbarcolor');
switch($navbarcolorsetting) {
case THEME_BOOST_UNION_SETTING_NAVBARCOLOR_DARK:
$templatecontext['navbarcolorclasses'] = 'navbar-dark bg-dark';
@@ -42,3 +41,10 @@
$templatecontext['navbarcolorclasses'] = 'navbar-light bg-white';
break;
}
+
+// If an alternative logo link URL is set.
+$alternativelogolinkurlsetting = get_config('theme_boost_union', 'alternativelogolinkurl');
+if (!empty($alternativelogolinkurlsetting)) {
+ // Add the logo link URL to templatecontext.
+ $templatecontext['alternativelogolinkurl'] = $alternativelogolinkurlsetting;
+}
diff --git a/settings.php b/settings.php
index 8caf2ad0601..787192d813d 100644
--- a/settings.php
+++ b/settings.php
@@ -1233,6 +1233,13 @@
$setting->set_updatedcallback('theme_reset_all_caches');
$tab->add($setting);
+ // Setting: Alternative logo link URL.
+ $name = 'theme_boost_union/alternativelogolinkurl';
+ $title = get_string('alternativelogolinkurlsetting', 'theme_boost_union', null, true);
+ $description = get_string('alternativelogolinkurlsetting_desc', 'theme_boost_union', null, true);
+ $setting = new admin_setting_configtext($name, $title, $description, '', PARAM_URL);
+ $tab->add($setting);
+
// Create user menu heading.
$name = 'theme_boost_union/usermenuheading';
$title = get_string('usermenuheading', 'theme_boost_union', null, true);
diff --git a/templates/theme_boost/navbar.mustache b/templates/theme_boost/navbar.mustache
index 05103af8b12..37a299485ee 100644
--- a/templates/theme_boost/navbar.mustache
+++ b/templates/theme_boost/navbar.mustache
@@ -64,6 +64,7 @@
* Removed the primary menu drawer hamburger menu, added bottom bar more section will help users to open the nav drawer.
* Display the logo on mobile viewport. (removed d-none, changed d-md-flex to d-flex)
* Added menu bar section.
+ * Added the possibility to use an alternative logo link URL.
}}
{{#menubar}}
@@ -80,7 +81,7 @@
{{/bottombar.drawer}}
-
+
{{# output.should_display_navbar_logo }}
diff --git a/tests/behat/theme_boost_union_feelsettings_navigation.feature b/tests/behat/theme_boost_union_feelsettings_navigation.feature
index daa6a4349fa..99c4e623ee6 100644
--- a/tests/behat/theme_boost_union_feelsettings_navigation.feature
+++ b/tests/behat/theme_boost_union_feelsettings_navigation.feature
@@ -46,6 +46,23 @@ Feature: Configuring the theme_boost_union plugin for the "Navigation" tab on th
| home,myhome | Home | Dashboard |
| courses,siteadminnode | My courses | Site administration |
+ Scenario Outline: Setting: Alternative logo link URL.
+ Given the following config values are set as admin:
+ | config | value | plugin |
+ | alternativelogolinkurl | | theme_boost_union |
+ And the following config values are set as admin:
+ # We set the start page to the Dashboard to be able to distinguish the used link URL by the '/my/' path later.
+ | config | value |
+ | defaulthomepage | 1 |
+ When I log in as "admin"
+ And I am on homepage
+ Then the "href" attribute of ".navbar-brand" "css_element" should contain ""
+
+ Examples:
+ | setting | href |
+ | | /my/ |
+ | https://foo.bar | https://foo.bar |
+
@javascript
Scenario Outline: Setting: Add preferred language link to language menu.
Given the following "language packs" exist: