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.
My menu icons on a custom menu disappear after I edit the page associated to the menu item.
So the menu item text stays - its just the icon that vanishes into the ether.
I read about a problem with menu items disappearing when no translation exists for a page. But all my pages have translations and menu icons showing perfectly to begin with. It's just when I edit the page that the icon goes missing for that language.
It seems it could be to do with i18n module as I do not recall this problem until I set up my site as multilingual.
Using Menu Icons 6.x-2.4 and i18 6.x-1.5.
Help anyone?
Comment | File | Size | Author |
---|---|---|---|
#2 | menu_icons_953456_2.patch | 1014 bytes | jtsnow |
Comments
Comment #1
abudev CreditAttribution: abudev commentedI found a simple solution, changing core modules/menu/menu.module:
function menu_nodeapi(&$node, $op) {
301 + if (isset($item['mlid'])) {
302 + $existing_item = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE mlid = %d", $item['mlid']));
303 + }
304 + $item['options']=unserialize($existing_item['options']);
Comment #2
jtsnow CreditAttribution: jtsnow commentedI've attached a patch that fixes this problem. Unlike the fix in the previous comment, it does not involve hacking core. I patched against the latest dev version of the module. The problem is that the menu module clears the values in
$form['menu']['options']
. See menu_form_alter(). In order to preserve the menu icon settings, they need to be stashed somewhere else while the menu module does its thing. Then, just before the node is saved, we can insert the menu icon settings back into the node object.Comment #3
bettibio CreditAttribution: bettibio commentedSame problem but do not seem related to the module menu. I removed all hook_node version 7 of menu.module:
hook_node_insert ()
hook_node_update ()
menu_node_save ($ node)
hook_node_delete ()
hook_node_prepare ()
menu_form_node_form_alter (& $ form, $ form_state)
menu_node_submit ($ node, $ form, $ form_state)
menu_form_node_type_form_alter (& $ form, $ form_state)
but the problem remains.
I'm using taxonomy menu to create menu items.
Comment #4
jenlamptonI don't think that last comment had anything to do with this issue, so changing the version back. Please open a new issue if you having a problem with the D7 version, or you can test this patch if you hare having this problem on D6.
Comment #5
bettibio CreditAttribution: bettibio commentedI had opened an issue for d7 Menu Icons disappear after editing page, but was closed as a duplicate of this. Excuse my ignorance but what should I do to properly report the problem and have workarounds for?
Comment #6
acrollet CreditAttribution: acrollet commentedbettibio: the code is quite similar in both versions, so it's generally simplest to track things in one issue. Probably the best way to move the issue forward would be to post steps to reproduce the problem when using an otherwise vanilla (no other contrib modules installed) copy of Drupal. (7 is fine, since that's what you're working with)
Comment #7
zznq CreditAttribution: zznq commentedThe issue as I saw it was that the module is modifying the options field in the menu_links table, which is a drupal core db table. It looks like whenever a node is altered, that has a relationship with the menu item, the menu_link record is updated and the options that this module is settings get overwritten. Perhaps Drupal core is being a bit too destructive.
My solution was to store the values in the menu_link table and somewhere else, in this case due to time I used variable_set. Maybe a menu_icon specific db would be better.
The real solution comes in by adding the menu_link_alter hook, this gets called whenever a menu_link gets saved. At this point I simply put the menu_icon values back into the menu_link options field. This seems to have fixed it for me.
Something like the following.
Comment #8
bettibio CreditAttribution: bettibio commentedIn my case the problem is caused by the taxonomy menu module. Uninstalling the problem disappears.
Comment #9
acrollet CreditAttribution: acrollet commentedSince there is a patch against version 6 in this issue, I'm changing this issue back to version 6. I've re-opened #1437184: Menu Icons disappear after editing page for Drupal 7, please post exact steps to reproduce.
Comment #10
emilorol CreditAttribution: emilorol commentedHi,
I posted a solution for Drupal 7 for this issue maybe something like that can be done for Drupal 6.
See it here: http://drupal.org/node/1437184#comment-5934980
Thank you,
Emil