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.
If hs_menu is active, you can't add menu items to a menu that doesn't have any menu items yet, using the menu admin form at admin -> structure -> menus -> list links -> add link .
This is due to the fact that menu_get_names(), called in hs_menu_hierarchical_select_valid_item(), gets the menu names from the menu_links table. The function will be removed in D8 in favour of menu_get_menus(), see http://drupal.org/node/784856.
Comment | File | Size | Author |
---|---|---|---|
#1 | hs_menu-cant_add_menu_items_to_empty_menu-1388308-1.patch | 486 bytes | firebird |
Comments
Comment #1
firebird CreditAttribution: firebird commentedHere's a patch that makes hs_menu_hierarchical_select_valid_item() call menu_get_menus() instead.
Comment #2
andypostsuppose isset() a bit better
Comment #3
firebird CreditAttribution: firebird commentedI think (can't remember, though) that I used array_key_exists for a reason. If $parts[0] is set to NULL, isset() will return FALSE, whereas array_key_exists() will return TRUE.
Comment #4
andypostI'm not sure that menu_get_names() returns a keyed array.
But checking for NULL inside array seems useless
Comment #5
Road Kill CreditAttribution: Road Kill commentedThanks for the patch Firebird I tried the patch but now I am getting
Notice: Undefined variable: parts in hs_menu_hierarchical_select_valid_item() (line 166 of C:\wamp\www\mysite\sites\all\modules\hierarchical_select\modules\hs_menu.module).
Any ideas anybody
Comment #6
Wim Leers@firebird: thanks! Perfect one-liner :) I also read #784856: Menu_get_names() is dead code, remove it and commented on menu_get_names()' docs: http://api.drupal.org/api/drupal/includes%21menu.inc/function/menu_get_n....
Commit: http://drupalcode.org/project/hierarchical_select.git/commit/4b88100.
Comment #8
xbery CreditAttribution: xbery commentedThis issue is actually still active. Sorry to reopen this but I had to manually patch the hs_menu.module file. Could the patch mentioned in #6 be committed in next release? It works great.
Comment #9
Wim LeersIt has been committed. No new release has been tagged though.
Comment #10
xbery CreditAttribution: xbery commentedYep I realised that the moment I posted this comment :-) Though it makes it harder for us who use this great module :-) I really appreciate the work that has been made but issues as serious as this must be fixed when solution is known and agreed to. Just my opinion :-)
(I got really scared when I couldn't save any menu item)
Comment #10.0
xbery CreditAttribution: xbery commentedSpecified where the adding of menu links doesn't work.