laravel-breadcrumbs

Basic Usage

Custom Templates

{note} laravel-breadcrumbs has been archived and is no longer maintained. Use caution when installing in your apps.

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.

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, or null if none was given
  • Any additional keys for each item in $data (see Custom Data)

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

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.

Previous
Defining Breadcrumbs