i m currently working on my first Drupal 8 site . We are almost ready to go in production, but i m facing a small but annoying problem. It seems like the breadcrumb hierarchy .

The problem:

If you browse between the pages you find in the head of the page  banner and breadcrumb the problem  in the 

display of the hierarchy of the breadcrumb   for exemple :

Home - services 

Home - service 1

Home - service 2

But i want the display be like :

Home - services 

Homes -services - service 1

Homes -services - service 2

What is the best/easiest way to fixe the breadcrumb

I realy hope someone could help me.

Kind regards,
Imen

Comments

vm’s picture

per https://www.drupal.org/forum/support/module-development-and-code-questio... please edit your post and move it to the 'post installation' forum. Thank you.

kle’s picture

If the "hierarchy" comes from your menu, this module helps: https://www.drupal.org/project/menu_breadcrumb

greg boggs’s picture

Just incase anyone else comes across this thread, you should not try to code your own custom breadcrumbs. You should install Easy Breadcrumb. You can find it here: https://www.drupal.org/project/easy_breadcrumb

If you want details for how to code your own breadcrumbs from scratch, it's a bit involved with about 500 total lines of code. You can find the solution great detail here: https://git.drupalcode.org/project/easy_breadcrumb/blob/8.x-1.x/src/EasyBreadcrumbBuilder.php

jaypan’s picture

If you want details for how to code your own breadcrumbs from scratch, it's a bit involved with about 500 total lines of code.

Well, it's not likely to take 500 lines for someone doing code specific to their site. That class you showed was a dynamic one to handle a wide array of situations.

Contact me to contract me for D7 -> D10/11 migrations.

greg boggs’s picture

If by "wide array of situations" you mean "displaying the correct breadcrumb on views pages, search pages, taxonomy pages, and node pages, and then expiring them when said page changes", then, um yes? That.

But, that's also kinda the goal of the stated OP above.

Now if someone needs breadcrumbs just on node detail pages, for example, then they could simplify the code quite a bit.

jaypan’s picture

Now if someone needs breadcrumbs just on node detail pages, for example, then they could simplify the code quite a bit.

Exactly.

Contact me to contract me for D7 -> D10/11 migrations.

VoodooSource’s picture

I find it hard to believe that anyone would want to go to the effort of a custom breadcrumb implementation simply for a content page. If you're going to do it, it will most likely require the full code mentioned above in my opinion ... It kind of feels like your comment is just to be awkward if im honest mate

greg boggs’s picture

Examples of things that will happen using simplified code often found on blog posts:

You'll edit a page, but the breadcrumb won't change unless you run cache clear all.

Certain pages will get duplicate breadcrumbs.

Certain pages will get a fall back title instead of the correct crumbs.

Breadcrumbs will break when you translate the site and not expire as expected.

liam morland’s picture

You can change the breadcrumbs by implementing hook_preprocess_HOOK() for breadcrumb, hook_preprocess_breadcrumb().