"Use menu title" with multiple menu items

Created on 27 July 2022, over 2 years ago
Updated 19 August 2024, 4 months ago

if you have a node in multiple menus e.g. in main (added via "create menu item" in node) and in footer (manually added link to menu) and the menu titles differ, you sometimes get the "wrong" titles. i would expect to get the one which was added via node-edit, but sometimes it is the other.

the reason is because easy_breadcrump just gets all the $menu_links as and afterwards gets the first element from the array $menu_link = reset($menu_links); but the first maybe is not the correct one...

          if ($this->config->get(EasyBreadcrumbConstants::USE_MENU_TITLE_AS_FALLBACK)) {

              // Try resolve the menu title from the route.
              $route_name = $route_match->getRouteName();
              $route_parameters = $route_match->getRawParameters()->all();
              $menu_links = $this->menuLinkManager->loadLinksByRoute($route_name, $route_parameters);

              if (empty($menu_links)) {
                ....
              }
              else {
                $menu_link = reset($menu_links);
                $title = $this->normalizeText($menu_link->getTitle());
                if (array_key_exists($title, $replacedTitles)) {
                  $title = $replacedTitles[$title];
                }
                if ($this->config->get(EasyBreadcrumbConstants::TRUNCATOR_MODE)) {
                  $title = $this->truncator($title);
                }
              }
            }
🐛 Bug report
Status

Postponed: needs info

Version

1.0

Component

Code

Created by

🇦🇹Austria crmn

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024