d13r / laravel-breadcrumbs

Please see the Diglactic fork.
https://github.com/diglactic/laravel-breadcrumbs
2.34k stars 416 forks source link

"Home" breadcrumb shows up twice, unable to remove it #199

Closed aalaap closed 6 years ago

aalaap commented 6 years ago

Here is my breadcrumb definition:

Breadcrumbs::for('index', function ($trail) {
    $trail->push('Home', route('frontend.index'));
});

Breadcrumbs::for('frontend.content.news.index', function ($trail) {
    $trail->parent('index');
    $trail->push('News', route('frontend.content.news.index'));
});

Breadcrumbs::for('frontend.content.news.show', function ($trail, $news) {
    $trail->parent('frontend.content.news.index');
    $trail->push($news->title, route('frontend.content.news.show', $news->slug));
});

This is how my breadcrumbs are shown:

  1. Homepage:

    Home / Home

  2. News index:

    Home / Home / News

  3. News detail

    Home / Home / News / This is a news item

The last items in each trail are linked, as is expected. The first Home is always present and unlinked. I have no breadcrumb defined as home. The one named index' is myhome`. There is no other code adding any other crumb to the trail. Where is the base home crumb coming from?

I have the same problem with the backend breadcrumbs. Home is always present and unlinked.

What am I getting confused with here?

d13r commented 6 years ago

No idea - looks right to me. Maybe it's in a different file somewhere, or if you have a custom template maybe accidentally hard-coded in there? But I can only guess.

aalaap commented 5 years ago

I found the problem: a home link was hard-coded in the view template before the loop!

d13r commented 5 years ago

👍