function node_export_get_menu in Node export 7.3
Same name and namespace in other branches
- 6.3 node_export.module \node_export_get_menu()
- 6.2 node_export.module \node_export_get_menu()
Create a new menu entry with title, parent and weight exported from another nodes menu. Returns NULL if the node has no menu title.
1 call to node_export_get_menu()
- node_export_prepare_node in ./
node_export.module - Prepare a single node during export.
File
- ./
node_export.module, line 946 - The Node export module.
Code
function node_export_get_menu($node) {
// This will fetch the existing menu item if the node had one.
module_invoke_all('node_prepare', $node);
$type = $node->type;
// Only keep the values we care about.
if (!empty($node->menu['mlid'])) {
// Store a copy of the old menu
$old_menu = $node->menu;
// Now fetch the defaults for a new menu entry.
$node = new stdClass();
$node->type = $type;
//module_invoke_all('node_prepare', $node);
node_object_prepare($node);
// Make a list of values to attempt to copy.
$menu_fields = array(
'link_title',
'plid',
'menu_name',
'weight',
'hidden',
'expanded',
'has_children',
);
// Copy those fields from the old menu over the new menu defaults.
foreach ($menu_fields as $menu_field) {
$node->menu[$menu_field] = $old_menu[$menu_field];
}
// Copy the menu description from the old menu.
// Issue #1287300.
if (isset($old_menu['options']['attributes']['title'])) {
$node->menu['description'] = $old_menu['options']['attributes']['title'];
}
else {
$node->menu['description'] = '';
}
// Ensure menu will be created during node import.
// Issue #1139120.
$node->menu['enabled'] = 1;
// Return the menu.
return $node->menu;
}
}