Same issue is here for version 6.x.2.4. After update node option menu icon is reset.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bettibio’s picture

Menu icon is rock but with this problem becomes unusable. No solution or suggestion?

acrollet’s picture

Status: Active » Closed (duplicate)

closing as duplicate of #953456: Menu Icons disappear after editing node associated with menu item - once the code has been fixed in one version, it'll be ported to the other.

acrollet’s picture

Version: 7.x-3.0-beta1 » 7.x-3.x-dev
Status: Closed (duplicate) » Postponed (maintainer needs more info)

Re-opening to track this issue in version 7. Please post exact steps to reproduce the issue.

acrollet’s picture

As a clarification, without a patch to review, I'll need exact steps to reproduce the issue from a clean drupal 7 install.

emilorol’s picture

Hi,

I can confirm this is happening.

1. A clean install of Drupal 7
2. Installation of menu, menu_icons, menu_taxonomy, menu_trails
3. Create a vocabulary and add some terms
4. Link the vocabulary to a menu (I used Main menu)
5. Go the to menu and upload images to the menu
6. Create a content type (enable the menus if you want the results are the same)
7. Add the vocabulary field if you don't have menus
8. Save
9. Create a new page using the content type you just created and watch how the icon on the menu is gone.

Thank you,
Emil

emilorol’s picture

FileSize
2.92 KB

Hi,

Well here is a patch that solves a couple of issues, but it is far from perfect. The current patch will use a site variable to store the menus options connected thru the menu link id (mlid) and then every time the css is regenerated the menu options are check against what is stored and if different they are loaded with the stored values and the changes are also saved on the menu_links table so that the process will not have to be repeated next time.

The idea behind this patch is to have an store location of the menu option in case they are deleted by any reason like when creating and/or updating a node.

Why it is far from perfect?

1. I you have created a menu with icons already by the time to apply this patch you will have to re-save all the menu items in order to get their options store outside the menu_links table.

2. Once you have an store copy of the menu options if you create or update a node the menu icon will show until you clear your cache.

Note: I tried another over killing solution forcing a regeneration using hook_node_update and hook_node_insert without luck.

Thank you,
Emil

agoradesign’s picture

Hi,
thanks for the patch Emil!! It did 99% of that what I needed and I've done the last steps by myself:

In order that Taxonomy Menu module stops overwriting the icon settings, I've done two things:

  1. implemented hook_taxonomy_menu_update()
  2. manipulated Taxonomy Menu module

Implementing hook_taxonomy_menu_update()

...is very easy. I've done it with an own module, but it wouldn't harm if Menu Icons would implement it like that:

function menu_icons_taxonomy_menu_update(&$item) {
  if (!empty($item['mlid']) && empty($item['options'])) {
    $item['options'] = unserialize(db_query('SELECT options FROM {menu_links} WHERE mlid = :mlid', array(':mlid' => $item['mlid']))->fetchField());
  }
}

But unfortunately that alone doesn't help if we don't

manipulate Taxonomy Menu module

Unfortunately the options property of the link item we have set above gets overridden by Taxonomy Menu module when saving because it is setting the options from ground up, no matter if the parameter already has set some options. So I've manipulated that module code and opened up an issue (which contains my proposed changes to that module): http://drupal.org/node/1579046

paknight’s picture

regarding #7 I'm a little confused as to how you got your results. Did you create a new .module file with-in menu_icons or an entire module to refer to this. I'm using the taxonomy menu, menu_icons and the nice menus. I performed the following

1)I have already applied the menu_icon.patch file
2)cut and pasted this function into the menu_icons.module file

I have no icons showing up.

Would appreciate help

Thank-you
Peter

emilorol’s picture

@paknight: try clearing the cache and if you re-build the menu then you might have to re-upload the files.

agoradesign’s picture

@paknight:
I created an entire new module to do this, just because it is cleaner to not modify an existing module if you have the choice. In this case you have to name the function according to your module's name: modulename_taxonomy_menu_update()

But of course it also works if you copy the function 1:1 into the menu_icons.module like you did.

The only reason why it didn't work, is, that you have missed out step 3: as I mentioned above you have to modify Taxonomy menu module also because the module is ignoring/overriding the options we are setting in our hook. See this issue for details how to modify that module: http://drupal.org/node/1579046

emilorol’s picture

@paknight:

as I mentioned above you have to modify Taxonomy module

Just as a quick note agoradesign mean the Taxonomy menu module and not the Taxonomy core module.

agoradesign’s picture

Thank you Emil! I have corrected my post

paknight’s picture

Thank-you for your reply. Sorry for taking so long to respond. I did your step 3 and added your code into the Taxonomy_menu.module and am still having the issue of the icons disappearing. I have worked little with the PHP and Drupal modules so I'm likely missing something. You added the statement "and set this $options array in the $item array instead" . Is this something else I need to do?

agoradesign’s picture

Hi,
oooops shame on me.... I was in hurry, when I wrote that post. I didn't mean $item array, but $link array. Above the code I've named it correctly: "You should do something like that before defining the $link array:" -> When you look at line 597 of the original code in the file taxonomy_menu.module, you see the def of the $link array, where 'options' is set from ground up. Here you should use your $options array as value instead

florisg’s picture

Version: 7.x-3.x-dev » 7.x-3.0-beta3
Status: Postponed (maintainer needs more info) » Needs review

Rebuild emilacosta patch against 7.x-3.0-beta3+0-dev

florisg’s picture

florisg’s picture

redo with right parameters: -ruN

emilorol’s picture

It looks good to me.

aisamat’s picture

I have the same issue.

Why not an official update of this module?

SKAUGHT’s picture

i've applied this patch [#17]and things seem to be working.

acrollet’s picture

Status: Needs review » Closed (won't fix)

I appreciate the effort by @emilacosta and @idevit, but unfortunately I'm not prepared to use this approach. The infinitely preferable approach is for taxonomy_menu to stop overwriting our (and possibly other module's) data, and the effort to change this may be followed here: #1579046: preserve menu link options when saving. If the taxonomy_menu maintainers express that they will not fix the issue from their side, we can re-open this issue and discuss the best approach to take. I've made a note on the project page that taxonomy_menu is currently incompatible with menu_icons.

JamesRobertson’s picture

I applied the patch and it doesn't work for me. Icons still disappear!

lightsurge’s picture

Same here although putting the code for the hook_taxonomy_menu_update into taxonomy_menu's own implementation of the hook got it working for me, so I guess it might be a module weight issue and it needs to go into a custom module with a higher weight than taxonomy_menu.

menu_icons and taxonomy_menu are both weight 0, so the code probably has to go in a custom module of at least weight 1... though I've not tested yet.

klimp’s picture

I've tested solution with custom module weighing more than 0 like as offered in #23 and it seens if works for me. I didn't modify taxonomy_menu module.

antonior14’s picture

Issue summary: View changes

Hi!
I tried to apply patches with this command on my linux webserver

curl https://www.drupal.org/files/menu_icons-icons_disappear_after_edit-14371... | patch -pl

patch: **** strip count l is not a number
but it returns (23) Failed writing bod

I use Drupal , and installed Menu Icons 7.x-3.0-beta4

thanks a lot

antonior14’s picture

Hi! When I tried to apply patches it returns

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2813 100 2813 0 0 7402 0 --:--:-- --:--:-- --:--:-- 7481
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- menu_icons.module.original 2012-07-03 15:04:37.955821463 +0200
|+++ menu_icons.module 2012-07-03 15:19:14.555823783 +0200
--------------------------
File to patch:

Can you help me, please?