function node_export_get_menu in Node export 6.3
Same name and namespace in other branches
- 6.2 node_export.module \node_export_get_menu()
- 7.3 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 693 - The Node export module.
Code
function node_export_get_menu($node) {
// This will fetch the existing menu item if the node had one.
node_invoke_nodeapi($node, 'prepare');
// Only keep the values we care about.
if (!empty($node->menu)) {
// Store a copy of the old menu
$old_menu = $node->menu;
// Now fetch the defaults for a new menu entry.
$node = NULL;
node_invoke_nodeapi($node, 'prepare');
// Make a list of values to attempt to copy.
$menu_fields = array(
'link_title',
'plid',
'menu_name',
'weight',
// These should import properly always.
'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];
}
// Return the menu.
return $node->menu;
}
}