laravel-breadcrumbs
Basic Usage
Custom Templates
On this page
{note} laravel-breadcrumbs has been archived and is no longer maintained. Use caution when installing in your apps.
{note} You're browsing the documentation for an old version of laravel-breadcrumbs. Consider upgrading your project to v4. Check your version with the following command:
`composer show rawilk/laravel-breadcrumbs`
Create a View
To customize the HTML, create your own view file (e.g. resources/views/partials/breadcrumbs.blade.php
), like this:
@if (count($breadcrumbs))
<ol class="breadcrumbs">
@foreach ($breadcrumbs as $breadcrumb)
@if ($breadcrumb->url && ! $loop->last)
<li class="breadcrumb-item">
<a href="{{ $breadcrumb->url }}">{{ $breadcrumb->title }}</a>
</li>
@else
<li class="breadcrumb-item active">{{ $breadcrumb->title }}</li>
@endif
@endforeach
</ol>
@endif
{tip} See the views/ directory for the built-in templates.
View Data
The view will receive an object called $breadcrumbs
.
Each breadcrumb is an object with the following keys:
-
title
- The breadcrumb title -
url
- The breadcrumb URL, ornull
if none was given - Any additional keys for each item in
$data
(see Custom Data)
Update the Config
When you create a custom view, you need to update the config/breadcrumbs.php
file with the custom view name:
'view' => 'partials.breadcrumbs', #--> resources/views/partials/breadcrumbs.blade.php
Override Template Views
Instead of creating your own custom view, you may choose to override one the package's pre-defined templates. You can do so by publishing the views:
php artisan vendor:publish --provider="Rawilk\Breadcrumbs\BreadcrumbsServiceProvider" --tag="views"
This will publish the views to resources/views/vendor/breadcrumbs
. From there, you can modify the views to fit your needs.