Download the PHP package aelora/laravel-breadcrumbs without Composer
On this page you can find all versions of the php package aelora/laravel-breadcrumbs. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download aelora/laravel-breadcrumbs
More information about aelora/laravel-breadcrumbs
Files in aelora/laravel-breadcrumbs
Package laravel-breadcrumbs
Short Description Quick and easy breadcrumbs for Laravel
License MIT
Homepage https://github.com/RyanNutt/laravel-breadcrumbs
Informations about the package laravel-breadcrumbs
Quickly build breadcrumb trails for your pages in Laravel and automatically output the HTML and JSON-LD schema metadata.
Installation
You can install the package via composer:
You can publish the config file with:
This is the contents of the published config file:
Optionally, you can publish the views using
Currently the only two views are jsonld.blade.php
which is used for the Schema metadata and breadcrumbs-tailwind.blade.css
.
Usage
You can also call $breadcrumbs->generate()
for the same effect. Breadcrumbs
implements Stringable
and has a __toString()
method, so you don't need to. The __toString()
calls generate()
.
Note that we're using {!!
and !!}
instead of {{
and }}
. We don't want the contents of the breadcrumbs to be escaped.
Home Page
You don't need to explicitly add your home page to the breadcrumbs. With the default config, it will be added automatically as the first element before output. If you don't want to include the home page link you can set home.include
to false
in the config file or call setHome(false)
when you're creating the breadcrumbs.
Methods
public function add(string $title, string $url = '', string $image = '')
Adds a new breadcrumb link on the end of the current stack.
The only required parameter is $title
. Breadcrumbs will only be links if $url
is not empty. If it is, $title
will display unlinked. $image
is a link to an image for the breadcrumb. It's currently only used in the schema metadata and not in the visible HTML output, although it could be if you build your own view.
public function count()
Returns the number of breadcrumb items, not counting the home link.
public static function create()
Returns a new instance so you can build on one line without having to call new Breadcrumbs()
.
public function generate($echo = false)
Returns the generated breadcrumbs, both the visible HTML and schema metadata. If $echo
is true
then the breadcrumbs will also be echoed prior to return.
public function reset()
Clears the breadcrumb trail.
public function reverse()
Reverses the internal breadcrumb trail. Sometimes it's easier to build the trail backwards and then flip it at the end.
public function setHome($title, string $url = '', string $image = '')
Allows you to change the home link for individual pages without having to change the config file. Parameters are the same as the add
method.
If $title
is false
then the home link will not be included. Otherwise it should be a string
.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
- Ryan Nutt
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-breadcrumbs with dependencies
spatie/laravel-package-tools Version ^1.9.2
illuminate/contracts Version ^9.0