aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoritz Strohm <strohm@data-quest.de>2024-05-28 14:31:53 +0000
committerMoritz Strohm <strohm@data-quest.de>2024-05-28 14:31:53 +0000
commitcc617253eb92d8e57d82dcc269a2f535681931a4 (patch)
tree1b5bb8ad15ac02bf3902eae9aa53923d273a17d5
parente9806e73f7d91f0810a298bc6c9139e6da138575 (diff)
display skip links for first and second navigagion layer only when there are elements, fixes #4049
Closes #4049 Merge request studip/studip!2949
-rw-r--r--app/controllers/start.php1
-rw-r--r--lib/classes/sidebar/Sidebar.php4
-rw-r--r--templates/header.php8
-rw-r--r--templates/tabs.php4
4 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/start.php b/app/controllers/start.php
index 3040d58..8231095 100644
--- a/app/controllers/start.php
+++ b/app/controllers/start.php
@@ -59,6 +59,7 @@ class StartController extends AuthenticatedController
$nav = $sidebar->addWidget(new NavigationWidget());
$nav->setTitle(_('Sprungmarken'));
+ $nav->setId('navigation-layer-3');
foreach (array_merge(...$this->columns) as $widget) {
$nav->addLink(
$widget->getPluginName(),
diff --git a/lib/classes/sidebar/Sidebar.php b/lib/classes/sidebar/Sidebar.php
index 65fc62d..ba1e609 100644
--- a/lib/classes/sidebar/Sidebar.php
+++ b/lib/classes/sidebar/Sidebar.php
@@ -186,7 +186,7 @@ class Sidebar extends WidgetContainer
static $actions_widget_added = false;
- if ($widget instanceof NavigationWidget && !$navigation_widget_added) {
+ if ($widget instanceof NavigationWidget && !$navigation_widget_added && $widget->hasElements()) {
SkipLinks::addIndex(
_('Dritte Navigationsebene'),
$widget->getId(),
@@ -197,7 +197,7 @@ class Sidebar extends WidgetContainer
$navigation_widget_added = true;
}
- if ($widget instanceof ActionsWidget && !$actions_widget_added) {
+ if ($widget instanceof ActionsWidget && !$actions_widget_added && $widget->hasElements()) {
if (!$widget->getId()) {
$widget->setId('sidebar-actions');
}
diff --git a/templates/header.php b/templates/header.php
index b875038..711d517 100644
--- a/templates/header.php
+++ b/templates/header.php
@@ -216,7 +216,9 @@ if ($navigation) {
<!-- Main navigation and right-hand logo -->
<nav id="navigation-level-1" aria-label="<?= _('Hauptnavigation') ?>">
- <? SkipLinks::addIndex(_('Hauptnavigation'), 'navigation-level-1', 2, false); ?>
+ <? if (!empty($header_nav['visible'])) : ?>
+ <? SkipLinks::addIndex(_('Hauptnavigation'), 'navigation-level-1', 2, false) ?>
+ <? endif ?>
<ul id="navigation-level-1-items" <? if (count($header_nav['hidden']) > 0) echo 'class="overflown"'; ?>>
<? foreach ($header_nav['visible'] as $path => $nav): ?>
<?= $this->render_partial(
@@ -297,10 +299,12 @@ if ($navigation) {
</div>
<? endif ?>
- <? SkipLinks::addIndex(_('Zweite Navigationsebene'), 'navigation-level-2', 910) ?>
<nav id="navigation-level-2" aria-label="<?= _('Zweite Navigationsebene') ?>">
<? if (PageLayout::isHeaderEnabled() /*&& isset($navigation)*/) : ?>
+ <? if (!empty($navigation)) : ?>
+ <? SkipLinks::addIndex(_('Zweite Navigationsebene'), 'navigation-level-2', 910) ?>
+ <? endif ?>
<?= $this->render_partial('tabs', compact('navigation')) ?>
<? endif; ?>
</nav>
diff --git a/templates/tabs.php b/templates/tabs.php
index 987e0fd..24597cb 100644
--- a/templates/tabs.php
+++ b/templates/tabs.php
@@ -7,10 +7,10 @@ foreach (Navigation::getItem("/")->getSubNavigation() as $path => $nav) {
}
?>
<div class="tabs_wrapper">
- <? SkipLinks::addIndex(_('Zweite Navigationsebene'), 'navigation-level-2', 10, false); ?>
<ul id="tabs">
<? if (!empty($navigation)): ?>
- <? foreach ($navigation as $path => $nav) : ?>
+ <? SkipLinks::addIndex(_('Zweite Navigationsebene'), 'navigation-level-2', 10, false); ?>
+ <? foreach ($navigation as $path => $nav) : ?>
<? if ($nav->isVisible()) : ?>
<li id="nav_<?= $path1 ?? '' ?>_<?= $path ?>"<?= $nav->isActive() ? ' class="current"' : '' ?>>
<? if ($nav->isEnabled()): ?>