Breadcrumbs do not work when the site running in a subfolder

Created on 1 April 2024, 9 months ago
Updated 24 April 2024, 8 months ago

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

πŸ› Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine rollins

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024