If a menu link item's db row has 1 assigned to the CUSTOMIZED field you can't alter the menu link using hook_menu_link_alter(). Is this by design? What's the purpose of the CUSTOMIZED field? I didn't want to just change the 1 to a 0 without knowing if I would be affecting functionality elsewhere.
Thanks,

Comments

ainigma32’s picture

Status: Active » Postponed (maintainer needs more info)

Yes this does seem to be by design. From system.install line 868:

A flag to indicate that the user has manually created or edited the link (1 = customized, 0 = not customized)

Maybe you could add a comment to this documentation page http://drupal.org/node/174891 ?

Does that answer your question ?

- Arie

frdesign’s picture

I added a comment as you suggested. Maybe someone can explain what would happen if this flag didn't prevent further customization of the menu link.
Thanks :-)
Freddy

jrockowitz’s picture

I did notice the hook_menu_link_alter() will execute when you add or edit a customize menu item. It just won't execute for 'customized' menu items when all the menus are rebuilt (using the Devel module).

ainigma32’s picture

@Freddy: maybe you would have better luck getting an answer on the forums, developer mailing list or IRC.

@jrockowitz: Not sure what you are saying. Could you explain using an example maybe?

- Arie

jrockowitz’s picture

hook_menu_link_alter() will only be executed when a link is saved via menu_link_save() (http://api.drupal.org/api/function/menu_link_save/6).

The issue is customized links will be not rebuilt when you access the admin module page (admin/build/modules) or use the Devel module's "Rebuild menus' link.
http://drupal.geek.nz/blog/how-rebuild-menu-drupal-6

Below is the code from the function that is causing your problem.
http://api.drupal.org/api/function/_menu_navigation_links_rebuild/6

function _menu_navigation_links_rebuild($menu) {
....
  //  This is the statement that ignores customized menu links
  if (!$existing_item || !$existing_item['customized']) {
     menu_link_save($item);
  }
...
}

The funny thing is, if you goto the edit link form for any menu item(admin/build/menu-customize/primary-links/edit) and click 'save', the menu_link_save() function is called and all the hook_menu_link_alter() hooks will be executed for just this single menu item.

Anyway, I know this is not the best answer.

Trying to address the original question. If you change a menu links table record from customized=1 to customized=0, and menu link was created be module, it will most likely be 'reset' to its default state the next time your menus are rebuilt. If you manually created the menu item either using 'Add item' (admin/build/menu-customize/primary-links/add) or adding the menu item from a node form then everything should be fine.

frdesign’s picture

Thanks for the thorough response and insights into Drupal's inner workings. I'm new to coding and I'm just beginning to learn my way around the Drupal universe. I think this thread will be very imformative should anyone else run into this issue.

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Active
ainigma32’s picture

Status: Active » Fixed

Answer provided so I'm setting this to fixed.

Feel free to reopen of you think that is wrong.

- Arie

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

xia325again’s picture

Issue summary: View changes

This information do help me understand the hook_menu_link_alter(), thank you for your information, guys!