Skip to content

Commit c8869d2

Browse files
Merge pull request #40 from TechnologyEnhancedLearning/feature/TD-6289-Add-descriptions-for-Admin-URL-theme-properties
Feature/td 6289 add descriptions for admin url theme properties
2 parents 0fd78b9 + 5b94b87 commit c8869d2

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

classes/output/core_renderer.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public function get_global_header_data() {
104104
$admin_link->url = new \moodle_url('/admin/search.php'); // Use the observed URL
105105
$admin_link->hasnotification = false;
106106
$admin_link->notificationcount = 0;
107-
$admin_link->openInNewTab = false; // Or true, if you prefer it opens in a new tab
107+
$admin_link->openInNewTab = false;
108108

109109
// Add this admin link to your customnavigation array
110110
// This ensures it gets rendered by your {{#customnavigation}} block in Mustache
@@ -180,6 +180,7 @@ public function get_global_header_data() {
180180
if (!isset($item['visible']) || $item['visible'] === true) {
181181
$processed_item = new \stdClass();
182182
$processed_item->title = $item['title'] ?? 'Untitled'; // Default title if missing
183+
$processed_item->openInNewTab = $item['openInNewTab'] ?? false;
183184
// Handle URLs - convert to moodle_url if internal, keep as string if external
184185
if (isset($item['url']) && !empty($item['url'])) {
185186
$item_url_path = $item['url']; // Store the raw URL from the API
@@ -188,6 +189,7 @@ public function get_global_header_data() {
188189
$admin_url = get_config('theme_nhse', 'admin_url');
189190
if (!empty($admin_url)) {
190191
$processed_item->url = $admin_url;
192+
$processed_item->openInNewTab = true;
191193
error_log("theme_nhse: Overriding 'Admin' URL with theme setting: {$processed_item->url}");
192194
} else {
193195
// Fallback to original logic if theme setting is not configured
@@ -216,8 +218,7 @@ public function get_global_header_data() {
216218
error_log("theme_nhse: Item has empty or missing URL, defaulting to Moodle home.");
217219
}
218220
$processed_item->hasnotification = $item['hasNotification'] ?? false;
219-
$processed_item->notificationcount = $item['notificationCount'] ?? 0;
220-
$processed_item->openInNewTab = $item['openInNewTab'] ?? false;
221+
$processed_item->notificationcount = $item['notificationCount'] ?? 0;
221222

222223
$processed_links[] = $processed_item;
223224
} else {

lang/en/theme_nhse.php

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

2525
defined('MOODLE_INTERNAL') || die();
2626

27+
$string['admin_url_setting'] = 'LH Admin URL';
28+
$string['admin_url_setting_desc'] = 'The full URL for the Learning Hub Admin page. This will be used to populate the Admin link URL.';
2729
$string['advancedsettings'] = 'Advanced settings';
2830
$string['api_base_url_setting'] = 'LH OpenAPI Base URL';
2931
$string['api_base_url_setting_desc'] = 'The base URL for the Learning Hub OpenAPI (e.g., https://lh-openapi.dev.local). This will be used to fetch user navigation data.';

templates/nav.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{{!-- BEGIN: Custom Navigation items --}}
3737
{{#customnavigation}}
3838
<li class="nhsuk-header__navigation-item nav-item" role="none"> {{!-- Added nhsuk-header__navigation-item and nav-item classes --}}
39-
<a class="nhsuk-header__navigation-link nav-link" href="{{url}}" role="menuitem"> {{!-- Added nhsuk-header__navigation-link and nav-link classes --}}
39+
<a class="nhsuk-header__navigation-link nav-link" href="{{url}}" role="menuitem" {{#openInNewTab}}target="_blank"{{/openInNewTab}}> {{!-- Added nhsuk-header__navigation-link and nav-link classes --}}
4040
{{title}}
4141
{{#hasnotification}}
4242
<span class="nhsuk-tag nhsuk-tag--notification">{{notificationcount}}</span> {{!-- Used NHS.UK tag for consistency --}}

0 commit comments

Comments
 (0)