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);
                }
              }
            }
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

crmn created an issue. See original summary.

greg boggs’s picture

Looks like we need to pull the correct menu! Merge Requests encouraged.

macdev_drupal made their first commit to this issue’s fork.

ankitjhakal’s picture

Assigned: Unassigned » ankitjhakal

Hi @greg, whats your suggestion here, can we fetch node title in else condition or we can make preferred menu field required. what you think???

$preferred_menu = $this->config->get(EasyBreadcrumbConstants::MENU_TITLE_PREFERRED_MENU);
                if ($preferred_menu) {
                  $preferred_found = FALSE;
                  foreach ($menu_links as $link) {
                    if ($link->getMenuName() == $preferred_menu) {
                      $menu_link = $link;
                      $preferred_found = TRUE;
                      break;
                    }
                  }
                  if (!$preferred_found) {
                    $menu_link = reset($menu_links);
                  }
                }
                <strong>else {
                  $menu_link = reset($menu_links);
                }</strong>

Or you are expecting to fetch menu link title from node edit form when no preferred menu is selected.
If any page is not an entity page(node page) then what will we do...

ankitjhakal’s picture

Assigned: ankitjhakal » Unassigned
spuky’s picture

is this still an issue since preferred menu option is there just asking if thats an issue for users ?

spuky’s picture

Status: Active » Postponed (maintainer needs more info)