I'm building my first Drupal site, so forgive me if this is a dumb question.

I would like to have my menus tightly bound to the nodes they point to, so that if I delete the menu item, the associated node gets deleted too.

Any tips on how I could accomplish this by using this module? Perhaps there is a php hook I can override to do this? I'm ok at php & sql so it seems like it would be doable given the menu/node link table this module provides.

Or am I looking in the wrong place, is there some other module that already has this functionality built-in?

thanks much

Comments

agentrickard’s picture

Using this module, try implementing hook_menu_node_delete(). You should not need to override anything. Just run node_delete() inside your function:

function custom_menu_node_delete($item, $node) {
  node_delete($node);
}

That should do it.

zeebo’s picture

Thanks for the reponse. I'm using this module http://drupal.org/project/menu_editor to do my menu item deletes as it's easier to delete a bunch at a time. I noticed when I deleted menu items through this module rather than via the standard drupal form, the corresponding menu_node table's row wasn't being deleted. I suppose this has something to do with which hooks are called & how they're implemented in each module. I don't know if this is by design or a possible conflict with that module, so perhaps you or someone else may wish to check into that.

In any case what I did was take your "node_delete($node);" line and use it inside that menu editor module right where menu link items are deleted and it works great. So thanks much for your help, you got me on the right track.

agentrickard’s picture

The problem is that D6 core has no menu CRUD hooks -- we DO have those in D7, I added them -- that means that menu_node.module has to watch a bunch of forms using hook_form_alter().

menu_node simple isn't aware of menu_editor. That's what causes the issue.

vuil’s picture

Issue summary: View changes
Status: Active » Closed (outdated)