Affecting menu item on node save...

jnicola's picture

Got a technical question for you all...

Working on some code, and I have to customize the experience of entering/updating a node in relationship to the menu items it creates. I'm bridging nodequeue and menu so as they're one in the same, and I need to control how new items are entered into menus.

I've tried to alter/affect menus (namely weight) in the following places to no avail:

hook_node_validate: You can't get the machine name for menu. No MLID exists yet to look it up with. Form value not absolutely passed. Closest is a string of menu-foo-bar:0. I could run a regex against that to remove the first menu- and last :0... but that feels janky to me...

hook_node_update: I change menu values on node here, but nothing happens. Menu must have already been generated?

hook_node_insert: Some story. Change $node menu values here, nothing happens. Menu must already be generated?

So... Any ideas on how to jump in front of menu item creation on nodes and customize said menu item? There are apparently no hooks in the core menu/link functionality, at least none my google-fu can reveal.


It sounds like you might want

calebtr's picture

It sounds like you might want hook_node_presave. I haven't tried it for your particular case, but it works if you want to programatically modify nodes during the save process.

More hook_node stuff than I ever needed:

I believe I tried

jnicola's picture

I believe I tried hook_node_presave() and at that point, menu appears to already have been generated.

I forget the specifics, but I just went with hook_node_validate(), did a few janks and made it work.

Jesse Nicola -- Shredical six different ways to Sunday! -- My Portfolio


Group categories

More Specifically

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week