How can we add our own breadcrumbs on custom pages (using our own routes/Controllers )
1 Answers
Hello Sebastian,
Under each module, there is a file under the routes folder called [module-name]_breadcrumbs.php, for example, "messaging_breadcrumbs.php", under this file you define the structure of the breadcrumbs for this module, for example
<?phpas you can see there is a discussions menu as a child for the dashboard and another two children for the discussion module, to render the create_ediit breadcrumb you have to add the following section in the template
//Discussion
Breadcrumbs::register('discussions', function ($breadcrumbs) {
$breadcrumbs->parent('dashboard');
$breadcrumbs->push(trans('Messaging::module.discussion.title'), url(config('messaging.models.discussion.resource_url')));
});
Breadcrumbs::register('discussion_create_edit', function ($breadcrumbs) {
$breadcrumbs->parent('discussions');
$breadcrumbs->push(view()->shared('title_singular'));
});
Breadcrumbs::register('discussion_show', function ($breadcrumbs) {
$breadcrumbs->parent('discussions');
$breadcrumbs->push(view()->shared('title_singular'));
});
@slot('breadcrumb')
{{ Breadcrumbs::render('discussion_create_edit') }}
@endslot
How can I add breadcrumbs to a non module?
Please provide full details so we can help
I’ve added in a new controller and route in web.php
Where can I defined the breadcrumbs
Please login or Register to submit your answer