ideas
ideas copied to clipboard
Can breadcrumbs include 404 errors?
Just a thought, but I think the breadcrumbs tag data should contain an indication of whether the current view is a 404 error, or other error response code. My opinion is that an error view is part of the breadcrumb trail and should be included.
The goal is to produce something like this on 404 error pages, and other error pages if required.

Current approach
At the moment I am working around by passing additional variables to my breadcrumbs partial on my error templates:
@include('partials.breadcrumbs', ['customBreadcrumb' => 'Page Not Found'])
@foreach(\Statamic::tag('nav:breadcrumbs')->fetch() as $item)
{{ -- Do the breadcrumb logic --}}
@endforeach
@if(isset($customBreadcrumb))
<span>{{ $customBreadcrumb }}</span>
@endif
Ideal approach
I think it would be better encapsulated if the breadcrumbs indicated that I was on an error page. Example:
@foreach( \Statamic::tag('nav:breadcrumbs')->fetch() as $item)
@if($item['is_current'] && $item['response_code'] == '404')
<span>Page Not Found</span>
@elseif
{{ -- Do the breadcrumb logic --}}
@endif
@endforeach