Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions classes/output/core_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function get_global_header_data() {
$admin_link->url = new \moodle_url('/admin/search.php'); // Use the observed URL
$admin_link->hasnotification = false;
$admin_link->notificationcount = 0;
$admin_link->openInNewTab = false; // Or true, if you prefer it opens in a new tab
$admin_link->openInNewTab = false;

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

$processed_links[] = $processed_item;
} else {
Expand Down
2 changes: 2 additions & 0 deletions lang/en/theme_nhse.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

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

$string['admin_url_setting'] = 'LH Admin URL';
$string['admin_url_setting_desc'] = 'The full URL for the Learning Hub Admin page. This will be used to populate the Admin link URL.';
$string['advancedsettings'] = 'Advanced settings';
$string['api_base_url_setting'] = 'LH OpenAPI Base URL';
$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.';
Expand Down
2 changes: 1 addition & 1 deletion templates/nav.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{{!-- BEGIN: Custom Navigation items --}}
{{#customnavigation}}
<li class="nhsuk-header__navigation-item nav-item" role="none"> {{!-- Added nhsuk-header__navigation-item and nav-item classes --}}
<a class="nhsuk-header__navigation-link nav-link" href="{{url}}" role="menuitem"> {{!-- Added nhsuk-header__navigation-link and nav-link classes --}}
<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 --}}
{{title}}
{{#hasnotification}}
<span class="nhsuk-tag nhsuk-tag--notification">{{notificationcount}}</span> {{!-- Used NHS.UK tag for consistency --}}
Expand Down