When I create a page I can add it's link to the menu. I use dropdown menus for child pages so I would like to have the menu items expanded by default.

I can do it like this in my module.

/**
* Implement hook_node_presave
*/
function mymodule_node_presave($node) {
  if($node->type = 'page' || $node->is_new) {
    $node->menu['expanded'] = 1;
  }
}

But... Node Hierarchy module doesn't preserve the setting. The problem is in nodehierarchy.module in function _nodehierarchy_save_node.

This can be avoided by adding this before the actual saving:

// Ensure that created menu item will inherit expanded value.
$node->nodehierarchy_menu_links[$i]['expanded'] = $node->menu['expanded'];

Sorry that I don't have a patch. I don't have properly configured environment at the moment.

Comments

jiv_e_old’s picture

Title: Cannot set created child page menu item expanded by default » Cannot set menu item expanded by default