Drupal-Version 10.2.2
PHP Version 8.1.26

I have the next code to generate breadcrumbs and render them as a custom variable

  public function getBreadcrumbs(EntityInterface $entity) {
    $routeName = $entity->toUrl()->getRouteName();
    $routeParameters = $entity->toUrl()->getRouteParameters();
    $route = $this->routeProvider->getRouteByName($routeName);
    $routeMatch = new RouteMatch($routeName, $route, $routeParameters, $routeParameters);

    return $this->easyBreadcrumb->build($routeMatch)->toRenderable();
  }

It works for regular websites, but if the website has a subfolder logic of setRouteContextFromRouteMatch method does not work
so I think that we need to add a subfolder check and remove it from the URL, to make breadcrumbs work

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rollins created an issue. See original summary.

rollins’s picture

Status: Active » Needs review

Attached MR with the fix for this bug

oleksandr.roshchuk’s picture

Confirm that the issue is fixed, thanks.

Greg Boggs made their first commit to this issue’s fork.

  • Greg Boggs committed e7b458cb on 2.x authored by rollins
    Issue #3437332 by rollins, oleksandr.roshchuk: Breadcrumbs do not work...
greg boggs’s picture

Status: Needs review » Fixed

Thanks!

  • Greg Boggs committed e7b458cb on feature/megre_dynamic-breadcrumbs authored by rollins
    Issue #3437332 by rollins, oleksandr.roshchuk: Breadcrumbs do not work...

Status: Fixed » Closed (fixed)

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