In Drupal 8, the main page still shows the link to "Home", even with the "Hide link to home page if it's the only breadcrumb item" option enabled. The desired behavior is to show no breadcrumbs on the main page.

I tested this with Bartik and a Bootstrap subtheme. In the Boostrap subtheme, the option to display the root breadcrumb is enabled. Both themes have this issue.

Thanks! : )

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

sudoman0 created an issue. See original summary.

sudoman0’s picture

I should note that the home page is a basic page with `/` as the URL path.

Greg Boggs’s picture

Hrm, try clearing the cache after switching themes. Easy Breadcrumb has code to expire the cache when things change, but Bootstrap does not.

sudoman0’s picture

I tried setting Bartik as the theme, enabling the Easy Breadcrumb option mentioned above, and clearing the Drupal cache, but the home breadcrumb remained.

The root node for my site is a 'Basic Page' with its URL set to '/'. Note that I also have the 'Include the front page as a segment in the breadcrumb' option enabled, and 'Display the front page segment on the front page' disabled.

I'm happy to show a breadcrumb on the main page, so this issue isn't super important for me.

Thanks! : )

Greg Boggs’s picture

Have you set a value for the front page crumb to Home or some other string? If you leave that field blank, that's the only thing I can think of. Here's the code in question

   $front = $this->siteConfig->get('page.front');

    // Give the option to keep the breadcrumb on the front page.
    $keep_front = !empty($this->config->get(EasyBreadcrumbConstants::HOME_SEGMENT_TITLE))
                  && $this->config->get(EasyBreadcrumbConstants::HOME_SEGMENT_KEEP);
    $exclude[$front] = !$keep_front;
    $exclude[''] = !$keep_front;
sudoman0’s picture

I set the home page string to a non-empty value.

Greg Boggs’s picture

Did that work?

sudoman0’s picture

Oh, sorry for the confusion. I already have a non-empty string enabled, but the breadcrumb still shows up on the main page.

Greg Boggs’s picture

I'm out of ideas on where the home crumb could be coming from!

Greg Boggs’s picture

Are you able to replicate the issue on Simply Test me?

https://simplytest.me/

junkuncz’s picture

That's pretty weird.
I started to debug it locally and my first conclusion is: it only happens if the frontpage global site setting is set to simply"/"
If I change to any other path then everything is working as expected.
I recon that it's not easy breadcrumb related bug because if I set slash as value of frontpage it stores a totally different value (/node/2 in my case) so strange.
I will continue the debugging soon.

Any ideas are welcome!

Cheers,

Bálint

Greg Boggs’s picture

Sounds like a bug in core $this->siteConfig->get('page.front'); to me!

Greg Boggs’s picture

Title: "Home" shown on home page, even though it's configured to be hidden » $this->siteConfig->get('page.front'); fails when front page is set to /
Greg Boggs’s picture

If that is indeed the cause, we can work around it could be somewhere lower in the code doesn't like the value of / for front page.

junkuncz’s picture

Well if I try to get the frontpage url in a different way then it's fine for me with a slash as well!

current code:
$front = $this->siteConfig->get('page.front');

my change:
$front = Url::fromRoute('<front>')->toString();

I know a static call is not the best inside this class but seems okay.

Probably a bit better idea to inject UrlGeneratorInterface to the class as a dependency.

You could have a look if you have time!

Thanks!

guaneagler’s picture

My configuration like the image upload below.
I want to hide the breadcrumb in the font, but it still shows in the front.
I have checked the code and find that it is caused by the front page path. drupal 8 set the real node path in 'page.front', eg: node/1.
When the code below executes, $front is not equal to the path to the front page.

if ($path && '/' . $path != $front && $path != $curr_lang) {
  $links[] = Link::createFromRoute($this->config->get(EasyBreadcrumbConstants::HOME_SEGMENT_TITLE), '<front>');
}
if ($this->config->get(EasyBreadcrumbConstants::HIDE_SINGLE_HOME_ITEM) && count($links) === 1) {
  return $breadcrumb->setLinks([]);
}

I solve this by add aliasManage and get the front page path alias for $front.

junkuncz’s picture

FileSize
5.2 KB

@guaneagler Yes your patch really solves the path problem BUT I found another one which is also an issue.
There is a foreach loop which iterates on the the path_crumb_rows which are set on the settings form IF it is set!
Currently this loop runs there is no replace path set and it's not fine that's the reason why the code never reaches the frontpage related part (in the foreach loop there is a return $breadcrumb->setLinks($links);)

I've attached a patch, please have look and test it yourself.

Hope that helps!

Bálint

junkuncz’s picture

Sorry this one should be okay let's see the tests.

junkuncz’s picture

Status: Active » Needs review
Greg Boggs’s picture

This is a lot of complex code that will give folks a white screen of death on module upgrade to work around a pretty obscure bug with front page settings. Can we solve this just by updating the help text on the front field?

junkuncz’s picture

That’s okay from my perspective.

junkuncz’s picture

I've added a note to the config form @Greg Boggs I hope you thought so. :)
Patch is attached.

renatog’s picture

Status: Needs review » Reviewed & tested by the community

The message can help other users. Makes sense

  • RenatoG committed 2fa0b4d on 8.x-1.x authored by junkuncz
    Issue #3070038 by junkuncz, guaneagler, Greg Boggs, sudoman0, RenatoG...
renatog’s picture

Status: Reviewed & tested by the community » Fixed

Committed to the dev branch.

Thank you all for helping

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.