Hello I'm trying to alter a content-type's menu options by code, since there will be new menus that keep being created on the site and I can't keep going back to the content type to keep adding every single menu to the Available Menus. I should be able to set the default available menus to all, or all custom... but I can't figure this out. I'm looking at the function menu_form_node_type_form_alter and created a module to override, however nothing changes, and the Main Menu is always the default available menu. I'm actually trying to prepopulate the parent menu through the URL, which only works if the parent menu is checked as available, but it's not working for all the new menus because the parent menu is not set as available ... How do I override the default menu option for a certain content type so that the available menu checkboxes gets set automatically to all of the custom menus that were created?

Thanks in advance!

update: still not figured out yet, but, I went straight into the core menu module and modified this piece of the function above:

  $form['menu']['menu_options'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Available menus'),
    '#default_value' => variable_get('menu_options_' . $type->type, array('main-menu')),
    '#options' => $menu_options,
    '#description' => t('The menus available to place links in for this content type.'),

changing the 'main-menu' to a different name actually works straight from core but doesn't work when trying to override with my own module.

1 Answer 1


If I understand you correctly you want to change the available menus for node types when new menus are created.

You can implement hook_menu_insert to respond to new menu creation and you can use variable_set to add the new menu to the available menus for the selected node types.

E.g. this will add all new menus to the page and article node types:

function mymodule_menu_insert($menu) {
  $types = array('page', 'article');
  foreach ($types as $type) {
    $menus = variable_get('menu_options_' . $type, array());
    $menus[] = $menu['menu_name'];
    variable_set('menu_options_' . $type, $menus);

If you already have created a bunch of custom menus, you'll basically need to call variable_set as in the example above.

  • you da man ! ! !
    – droopie
    Commented Sep 5, 2014 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.