Skip to content

Commit

Permalink
Feature: Allow the admin to change the link behind the logo in the na…
Browse files Browse the repository at this point in the history
…vbar, resolves moodle-an-hochschulen#565.
  • Loading branch information
abias authored and lucaboesch committed Feb 22, 2024
1 parent 29940b0 commit 69d1a80
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 3 deletions.
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

* 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
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions lang/en/theme_boost_union.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br /><br />
Please note: Here, you can just remove navigation nodes. But if you want to add custom navigation nodes, please consider using <a href="{$a->url}">Boost Union\'s smart menu functionality</a>.';
// ... ... 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.
Expand Down
10 changes: 8 additions & 2 deletions layout/includes/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
}
7 changes: 7 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion templates/theme_boost/navbar.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand All @@ -80,7 +81,7 @@
</button>
{{/bottombar.drawer}}

<a href="{{{ config.homeurl }}}" class="navbar-brand align-items-center m-0 mr-4 p-0 aabtn {{#bottombar.drawer}} d-flex {{/bottombar.drawer}} {{^bottombar.drawer}} d-none d-md-flex {{/bottombar.drawer}} ">
<a href="{{#alternativelogolinkurl}}{{{alternativelogolinkurl}}}{{/alternativelogolinkurl}}{{^alternativelogolinkurl}}{{{ config.homeurl }}}{{/alternativelogolinkurl}}" class="navbar-brand align-items-center m-0 mr-4 p-0 aabtn {{#bottombar.drawer}} d-flex {{/bottombar.drawer}} {{^bottombar.drawer}} d-none d-md-flex {{/bottombar.drawer}} ">

{{# output.should_display_navbar_logo }}
<img src="{{output.get_compact_logo_url}}" class="logo mr-1" alt="{{sitename}}">
Expand Down
17 changes: 17 additions & 0 deletions tests/behat/theme_boost_union_feelsettings_navigation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | <setting> | 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 "<href>"

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:
Expand Down

0 comments on commit 69d1a80

Please sign in to comment.