Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When a particular menu is set as the default for a content type, and a node of that type is edited, Drupal is supposed to select a menu entry from that menu in preference to other menu links to the node:
// Give priority to the default menu
$mlid = db_query_range("SELECT mlid FROM {menu_links} WHERE link_path = :path AND menu_name = :menu_name AND module = 'menu' ORDER BY mlid ASC", 0, 1, array(
':path' => 'node/' . $node->nid,
':menu_name' => $menu_name,
))->fetchField();
The problem is that $menu_name contains a menu option 'main-menu:0' not a menu name 'main-menu'. This issue also impacts the default values that are provided, including new nodes.
Comment | File | Size | Author |
---|---|---|---|
#4 | node-menu-default-1156128.patch | 619 bytes | lyricnz |
#1 | node-menu-default-1156128.patch | 699 bytes | lyricnz |
Comments
Comment #1
lyricnz CreditAttribution: lyricnz commentedPatch
Comment #2
sun$menu_name = explode(':' $menu_name);
$menu_name = $menu_name[0];
cuts it.
Powered by Dreditor.
Comment #3
sunEven better yet:
$menu_name = strtok($menu_name, ':');
Comment #4
lyricnz CreditAttribution: lyricnz commentedThanks, Updated to use strtok().
Comment #5
lyricnz CreditAttribution: lyricnz commentedThis fix is rolled into #761648: Menu D6->D7 upgrade doesn't maintain node-menu configuration (f.k.a.: Menu items disappear after upgrade or manual menu entry) which is RTBC, so I'll close this one as a duplicate.