Closed alberto-bottarini closed 3 years ago
I can understand the need for this, but I can't see this being cleanly achievable. If you'd like to submit a PR for this, I'll take a look, but I won't personally be coding this any time soon.
What about something like this:
if (method_exists($this->model, 'generateBreadcrumbs')) {
$this->model->generateBreadcrumbs(function($title, $url) {
$this->appendToCrumbs($title, $url);
});
return $this->getCrumbs();
}
You delegate the invocation of appendToCrumbs
to the resource
I think I have a solution for this, when I have time to work on Version 3. I basically want to offset the logic of generating the breadcrumbs to a manager of some form. That would enable a global overwrite of how the breadcrumbs work, but on top of that, I'd enable it to process them on a Resource basis, thus allowing the behaviour you've discussed above.
Here's my scenario:
I have two models:
Topic hasMany Post while Post belongsTo Topic.
I disabled post in left menu so that user can "navigate" only starting from Topic. Topic detail page has a Posts list.
I would like to customize Post breadcrumb in order to avoid "index page" because this page is "hidden" from users.
I would like to have something like:
Home / $titleOfTheTopic / $titleOfThePost
instead of the standard breadcrumb:
Home / Post Index / $titleOfThePost
It would be nice to have the possibility to override standard structure inside my resources
What do you think?