- Issue created by @sassafrass
- πΊπΈUnited States Greg Boggs Portland Oregon
I hacked this together from Stack Exchange. I'm sure there's a much cleaner way to code that :)
https://drupal.stackexchange.com/questions/191548/how-do-i-build-breadcr...
/** * Override or insert variables into the node template. * * @param $vars * An array of variables to pass to the theme template. */ function multcolibtheme_preprocess_node(&$variables) { if (\Drupal::routeMatch()->getRouteName() == 'view.library_locations.page_1') { if (in_array($variables['node']->id(), array_column($variables['view']->result, 'nid'))) { // Initialize an array to store breadcrumbs for nodes in the view. $breadcrumbs = []; // Loop through each result in the view. foreach ($variables['view']->result as $result) { if ($result->nid == $variables['node']->id()) { // Set the context to the current node. $node = \Drupal\node\Entity\Node::load($variables['node']->id()); if ($node) { $routeName = $node->toUrl()->getRouteName(); $routeParameters = $node->toUrl()->getRouteParameters(); $route = Drupal::service('router.route_provider')->getRouteByName($routeName); $routeMatch = new Drupal\Core\Routing\RouteMatch($routeName, $route, $routeParameters, $routeParameters); $variables['search_breadcrumb'] = Drupal::service('easy_breadcrumb.breadcrumb')->build($routeMatch)->toRenderable(); } } } } } }
- πΊπΈUnited States Greg Boggs Portland Oregon
I didn't add a template, and I'm not sure about the toRenderable() bit on the end there. But, that code should be close.
- πΊπΈUnited States sassafrass
Awesome! That worked! Thank-you so much!
- Status changed to Fixed
over 1 year ago 4:11pm 6 September 2023 Automatically closed - issue fixed for 2 weeks with no activity.