-
Notifications
You must be signed in to change notification settings - Fork 415
How to add icon to breadcrumbs? #34
Comments
You could probably pass HTML (or maybe even an array) as the $title parameter and customise the template. |
could you example for me? |
This is untested: $breadcrumbs->push('<img src="home.png">Home', route('home')); Template (replaced <li><a href="{{{ $breadcrumb->url }}}">{{ $breadcrumb->title }}</a></li> You'd have to be sure to escape any titles from other sources with Laravel's I've opened #35 for possibly adding arbitrary data to breadcrumbs some time in the future which would make it easier and more flexible. In the mean time you could try passing an array as the title as a workaround - but I'm not sure if it will work or not, again I haven't tested this. $breadcrumbs->push(['title' => 'Home', 'icon' => 'home.png'], route('home')); <li><a href="{{{ $breadcrumb->url }}}"><img src="{{{ $breadcrumb->title['icon'] }}}">{{{ $breadcrumb->title['title'] }}}</a></li> |
Very Thanks |
In 2.3.0 it's now possible to add arbitrary data in the third parameter: $breadcrumbs->push('Home', route('home'), ['icon' => 'home.png']); <li><a href="{{{ $breadcrumb->url }}}"><img src="{{{ $breadcrumb->icon }}}">{{{ $breadcrumb->title }}}</a></li> |
@davejamesmiller how about like this? <?php
Breadcrumbs::register('admin.dashboard', function ($breadcrumbs)
{
$breadcrumbs->push('<i class="fa fa-fw fa-dashboard"></i> Dashboard', route('admin.dashboard'));
}); |
@lloricode Only if you create a custom template that doesn't escape the title - which is a security risk as you'll have to manually escape every title. Also it's best practice to keep the HTML in the view. |
@davejamesmiller hmm good idea, maybe just create a view Thanks :) |
How to add icon to breadcrumbs.
Pl example.
The text was updated successfully, but these errors were encountered: