API page: https://api.drupal.org/api/drupal/modules%21menu%21menu.module/7.x

In review of the menu.module file from Drupal Core, we have found that there is a recursive helper function, _menu_parents_recurse,
which returns the Parent Item while editing a node (node/edit) under Menu Settings. The lines in questions are below, but in the following scenario below we are finding that the menu links that are not in the current language are disabled with "(disabled)" and it is causing a lot of conflicts while editing. For example, if i am in the en-gb interface (British English), it will show US menu links as disabled, but i can still add it under the US menu links. Then if i accidently put it under a US menu link, when the page is rendered (node/view), i am not able to see the menu link while on a node where language = en-gb since the menu link was placed under the US.

The Parent Item under Menu Setting while editing a page (node/edit) should be more intuitive to take the current node's language and only display the Parent Item whose menu link language = node's language.

Desired scenario:

  • If the node's language is en then only show menu link items where menu link language = en.
  • if node's language is set to es, then only menu link where menu link language = es

Current workaround:

modify the current menu.module file (docroot/modules/menu/menu.module) to the following for the recursive function. Which was to basically only add $title to $options array if $data['link']['hidden'] is false

/**
 * Recursive helper function for menu_parent_options().
 */
function _menu_parents_recurse($tree, $menu_name, $indent, &$options, $exclude, $depth_limit) {
  foreach ($tree as $data) {
    if ($data['link']['depth'] > $depth_limit) {
      // Don't iterate through any links on this level.
      break;
    }
    if ($data['link']['mlid'] != $exclude && $data['link']['hidden'] >= 0) {
      $title = $indent . ' ' . truncate_utf8($data['link']['title'], 30, TRUE, FALSE);
      if ($data['link']['hidden']) {
        $title .= ' (' . t('disabled') . ')';
      }
      else {
      	$options[$menu_name . ':' . $data['link']['mlid']] = $title;	
      }
      
      if ($data['below']) {
        _menu_parents_recurse($data['below'], $menu_name, $indent . '--', $options, $exclude, $depth_limit);
      }
    }
  }
}
CommentFileSizeAuthor
#2 menu link disabled.png15.18 KBdrup16
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

raj.ruprai created an issue. See original summary.

drup16’s picture

FileSize
15.18 KB
drup16’s picture

Issue summary: View changes
drup16’s picture

Issue summary: View changes