Skip to content

Commit 34682b5

Browse files
scott graysonscott grayson
authored andcommitted
feat: add breadcrumb navigation to edit and view pages
- Add getBreadcrumbs() method to EditLibraryItem page - Add getBreadcrumbs() method to ViewLibraryItem page - Breadcrumbs show full folder hierarchy from root to current item - Includes current item name as final breadcrumb - Consistent navigation experience across all library pages
1 parent dff2d7c commit 34682b5

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

src/Resources/Pages/EditLibraryItem.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,32 @@ protected function getForms(): array
105105
];
106106
}
107107

108+
public function getBreadcrumbs(): array
109+
{
110+
$breadcrumbs = [
111+
static::getResource()::getUrl() => 'All Folders',
112+
];
113+
114+
$record = $this->getRecord();
115+
116+
if ($record->parent_id) {
117+
$current = $record->parent;
118+
$path = [];
119+
120+
while ($current) {
121+
array_unshift($path, $current);
122+
$current = $current->parent;
123+
}
124+
125+
foreach ($path as $folder) {
126+
$breadcrumbs[static::getResource()::getUrl('index', ['parent' => $folder->id])] = $folder->name;
127+
}
128+
}
129+
130+
// Add current item to breadcrumbs
131+
$breadcrumbs[] = $record->name;
132+
133+
return $breadcrumbs;
134+
}
135+
108136
}

src/Resources/Pages/ViewLibraryItem.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,32 @@ protected function getHeaderActions(): array
3737

3838
return $actions;
3939
}
40+
41+
public function getBreadcrumbs(): array
42+
{
43+
$breadcrumbs = [
44+
static::getResource()::getUrl() => 'All Folders',
45+
];
46+
47+
$record = $this->getRecord();
48+
49+
if ($record->parent_id) {
50+
$current = $record->parent;
51+
$path = [];
52+
53+
while ($current) {
54+
array_unshift($path, $current);
55+
$current = $current->parent;
56+
}
57+
58+
foreach ($path as $folder) {
59+
$breadcrumbs[static::getResource()::getUrl('index', ['parent' => $folder->id])] = $folder->name;
60+
}
61+
}
62+
63+
// Add current item to breadcrumbs
64+
$breadcrumbs[] = $record->name;
65+
66+
return $breadcrumbs;
67+
}
4068
}

0 commit comments

Comments
 (0)