F
Filamentβ€’13mo ago
Husky110

Disable or modify Breadcrumbs

Hey - I couldn't figure it out with the docs or searching the help ( πŸ˜‰ ), so hopefully someone with experience can answer me my three questions. πŸ™‚ Given the following scenario: I got a resource that is listing articles and was created with the --view-Parameter. Now when I open one of the listed articles I would expect the breadcrumb to be like Articles -> Listing -> ArticlenameXYZ (whatever the model itself says in the column "articlename"). But 2 problems with that: - The Listing is beeing skipped... -> How do I fix that? - I can set a static name via protected static ?string $breadcrumb, but how can I set a dynamic one? And lastly (since I might need it later): How can I disable Breadcrumbs on a page?
12 Replies
Dan Harrin
Dan Harrinβ€’13mo ago
you can override the getBreadcrumbs() method on any page and return an array of url=>label entries so you can do whatever you want with that, add your own items, remove all of them
Husky110
Husky110β€’13mo ago
Thanks - I got this far myself by now. πŸ™‚ But doesn't seem to work on Resources? For anyone looking this up in Discord:
protected function getBreadcrumbs(): array
{
return [
'URL1' => 'NAME1',
'URLLAST' => 'NAMELAST',
];
}
protected function getBreadcrumbs(): array
{
return [
'URL1' => 'NAME1',
'URLLAST' => 'NAMELAST',
];
}
Works at least on Pages... How do I do that on a Resource? Setting protected static ?string $breadcrumb = ''; or protected static ?string $breadcrumb = null; seems to have no effect and the getBreadcrumb-Function only seems to set the last entry and not the overall breadcrumb.
Dan Harrin
Dan Harrinβ€’13mo ago
return [] from the getBreadcrumbs
Husky110
Husky110β€’13mo ago
getBreadcrumbs() is not defined in a Resource and even writing it with retun [] has no effect. I'm talking about the Resource-Listing here. πŸ™‚
Dan Harrin
Dan Harrinβ€’13mo ago
it should be on the page class, not the resource class
Husky110
Husky110β€’13mo ago
so do I have to create a separate listing-page and can not just use the table-function? and define it within the resource?
Dan Harrin
Dan Harrinβ€’13mo ago
i dont know what you mean, sorry the List page exists already
Husky110
Husky110β€’13mo ago
Okay - maybe I need to clarify. πŸ™‚ I made a Resource which created the listing-page for me (hence the table-function). I do not want a breadcrumb there. Like above the listing. There is one - I want it gone. How do I achieve that? πŸ™‚
Husky110
Husky110β€’13mo ago
Dan Harrin
Dan Harrinβ€’13mo ago
look at the files in the Pages/ directory of the resource there is a list page
Husky110
Husky110β€’13mo ago
Thank you! The page-file was the missing peace there. πŸ˜„