Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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! : )
Comment | File | Size | Author |
---|---|---|---|
#22 | fontpage_note.patch | 949 bytes | junkuncz |
| |||
#18 | path_2.patch | 9.33 KB | junkuncz |
#16 | get-front-page-alias.patch | 4.26 KB | guaneagler |
| |||
#16 | image (3).png | 72.1 KB | guaneagler |
#16 | image (2).png | 95.31 KB | guaneagler |
Comments
Comment #2
sudoman0 CreditAttribution: sudoman0 commentedI should note that the home page is a basic page with `/` as the URL path.
Comment #3
Greg BoggsHrm, try clearing the cache after switching themes. Easy Breadcrumb has code to expire the cache when things change, but Bootstrap does not.
Comment #4
sudoman0 CreditAttribution: sudoman0 commentedI 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! : )
Comment #5
Greg BoggsHave 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
Comment #6
sudoman0 CreditAttribution: sudoman0 commentedI set the home page string to a non-empty value.
Comment #7
Greg BoggsDid that work?
Comment #8
sudoman0 CreditAttribution: sudoman0 commentedOh, sorry for the confusion. I already have a non-empty string enabled, but the breadcrumb still shows up on the main page.
Comment #9
Greg BoggsI'm out of ideas on where the home crumb could be coming from!
Comment #10
Greg BoggsAre you able to replicate the issue on Simply Test me?
https://simplytest.me/
Comment #11
junkuncz CreditAttribution: junkuncz at Petend commentedThat'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
Comment #12
Greg BoggsSounds like a bug in core $this->siteConfig->get('page.front'); to me!
Comment #13
Greg BoggsComment #14
Greg BoggsIf 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.
Comment #15
junkuncz CreditAttribution: junkuncz at Petend commentedWell 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!
Comment #16
guaneagler CreditAttribution: guaneagler commentedMy 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.
I solve this by add aliasManage and get the front page path alias for $front.
Comment #17
junkuncz CreditAttribution: junkuncz at Petend commented@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
Comment #18
junkuncz CreditAttribution: junkuncz at Petend commentedSorry this one should be okay let's see the tests.
Comment #19
junkuncz CreditAttribution: junkuncz at Petend commentedComment #20
Greg BoggsThis 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?
Comment #21
junkuncz CreditAttribution: junkuncz at Petend commentedThat’s okay from my perspective.
Comment #22
junkuncz CreditAttribution: junkuncz at Petend commentedI've added a note to the config form @Greg Boggs I hope you thought so. :)
Patch is attached.
Comment #23
renatogThe message can help other users. Makes sense
Comment #25
renatogCommitted to the dev branch.
Thank you all for helping