Skip to content

Commit

Permalink
[5.x] Add option to add filters from collection/taxonomy list to brea…
Browse files Browse the repository at this point in the history
…dcrumb »back« link in single view (#11243)

Co-authored-by: Florian Brinkmann <[email protected]>
  • Loading branch information
florianbrinkmann and florianbrinkmann authored Dec 17, 2024
1 parent b70a97b commit bccb3a0
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/Entries/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,14 @@ public function showUrl()
return cp_route('collections.show', $this->handle());
}

public function breadcrumbUrl()
{
$referer = request()->header('referer');
$showUrl = $this->showUrl();

return $referer && Str::before($referer, '?') === $showUrl ? $referer : $showUrl;
}

public function editUrl()
{
return cp_route('collections.edit', $this->handle());
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/CP/Collections/EntriesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ protected function breadcrumbs($collection)
],
[
'text' => $collection->title(),
'url' => $collection->showUrl(),
'url' => $collection->breadcrumbUrl(),
],
]);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Controllers/CP/Taxonomies/TermsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ protected function breadcrumbs($taxonomy)
],
[
'text' => $taxonomy->title(),
'url' => $taxonomy->showUrl(),
'url' => $taxonomy->breadcrumbUrl(),
],
]);
}
Expand Down
8 changes: 8 additions & 0 deletions src/Taxonomies/Taxonomy.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ public function showUrl()
return cp_route('taxonomies.show', $this->handle());
}

public function breadcrumbUrl()
{
$referer = request()->header('referer');
$showUrl = $this->showUrl();

return $referer && Str::before($referer, '?') === $showUrl ? $referer : $showUrl;
}

public function editUrl()
{
return cp_route('taxonomies.edit', $this->handle());
Expand Down

0 comments on commit bccb3a0

Please sign in to comment.