Skip to content

Commit bd844a2

Browse files
authored
Merge pull request #6678 from WoltLab/63-acp-breadcrumbs
Add breadcrumb navigation to the ACP
2 parents 226386c + 7800fcb commit bd844a2

4 files changed

Lines changed: 89 additions & 3 deletions

File tree

wcfsetup/install/files/acp/style/layout.scss

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ html[data-color-scheme="dark"] {
508508
flex: 1 1 auto;
509509

510510
@include screen-lg {
511-
padding: 40px 0;
511+
padding: 30px 0;
512512
}
513513

514514
@include screen-md-down {
@@ -1066,3 +1066,35 @@ html[data-color-scheme="dark"] {
10661066

10671067
@include wcfFontSmall;
10681068
}
1069+
1070+
.acpBreadcrumbs {
1071+
margin-bottom: 5px;
1072+
}
1073+
1074+
.acpBreadcrumbs__list {
1075+
display: flex;
1076+
align-items: center;
1077+
gap: 5px;
1078+
color: var(--wcfContentDimmedText);
1079+
1080+
@include wcfFontSmall;
1081+
}
1082+
1083+
.acpBreadcrumbs__item {
1084+
display: flex;
1085+
align-items: center;
1086+
gap: 5px;
1087+
}
1088+
1089+
.acpBreadcrumbs__item__separator {
1090+
display: flex;
1091+
}
1092+
1093+
.acpBreadcrumbs__item__link {
1094+
color: inherit;
1095+
1096+
&:hover {
1097+
color: inherit;
1098+
text-decoration: underline;
1099+
}
1100+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{if PACKAGE_ID && $__wcf->user->userID && $__isLogin|empty}
2+
{hascontent}
3+
<nav class="acpBreadcrumbs" aria-label="{lang}wcf.page.breadcrumb{/lang}">
4+
<ol class="acpBreadcrumbs__list">
5+
{content}
6+
{foreach from=$__wcf->getACPMenu()->getBreadcrumbs() item='acpBreadcrumb' name='acpBreadcrumbs'}
7+
<li class="acpBreadcrumbs__item">
8+
{if $acpBreadcrumb->getLink()}
9+
<a class="acpBreadcrumbs__item__link" href="{$acpBreadcrumb->getLink()}">
10+
<span class="acpBreadcrumbs__item__title">{$acpBreadcrumb}</span>
11+
</a>
12+
{else}
13+
<span class="acpBreadcrumbs__item__title">{$acpBreadcrumb}</span>
14+
{/if}
15+
16+
{if !$tpl.foreach.acpBreadcrumbs.last}
17+
<span class="acpBreadcrumbs__item__separator" aria-hidden="true">
18+
<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 6l6 6-6 6"></path></svg>
19+
</span>
20+
{/if}
21+
</li>
22+
{/foreach}
23+
{/content}
24+
</ol>
25+
</nav>
26+
{/hascontent}
27+
{/if}

wcfsetup/install/files/acp/templates/header.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@
188188

189189
<div id="acpPageContentContainer" class="acpPageContentContainer">
190190
{include file='pageMenu'}
191-
191+
192192
<section id="main" class="main" role="main">
193193
<div class="layoutBoundary">
194194
<div id="content" class="content">
195-
195+
{include file='breadcrumbs'}

wcfsetup/install/files/lib/system/menu/acp/ACPMenu.class.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,31 @@ protected function removeEmptyItems(string $parentMenuItem = '')
115115
}
116116
}
117117
}
118+
119+
/**
120+
* Returns the breadcrumb items for the active menu path, ordered from the
121+
* top-level section down to the immediate parent of the current page. The
122+
* current page itself is omitted.
123+
*
124+
* @return AcpMenuItem[]
125+
* @since 6.3
126+
*/
127+
public function getBreadcrumbs(): array
128+
{
129+
if ($this->activeMenuItems === []) {
130+
return [];
131+
}
132+
133+
$names = \array_reverse($this->activeMenuItems);
134+
\array_pop($names);
135+
136+
$breadcrumbs = [];
137+
foreach ($names as $name) {
138+
if (isset($this->menuItemList[$name])) {
139+
$breadcrumbs[] = $this->menuItemList[$name];
140+
}
141+
}
142+
143+
return $breadcrumbs;
144+
}
118145
}

0 commit comments

Comments
 (0)