You are here

function clone_node_clone_menu_link in Node clone 6

Same name and namespace in other branches
  1. 7 clone.pages.inc \clone_node_clone_menu_link()

Create a new menu link cloned from another node.

Returns NULL if no existing link, or links are not to be cloned.

2 calls to clone_node_clone_menu_link()
clone_node_prepopulate in ./clone.pages.inc
Clones a node - prepopulate a node editing form
clone_node_save in ./clone.pages.inc
Clones a node by directly saving it.

File

./clone.pages.inc, line 119
Additional functions for Node_Clone module.

Code

function clone_node_clone_menu_link($node) {
  if (variable_get('clone_menu_links', FALSE)) {

    // This will fetch the existing menu link if the node had one.
    node_invoke_nodeapi($node, 'prepare');
    if (!empty($node->menu['mlid'])) {
      $old_link = $node->menu;
      $link['link_title'] = t('Clone of !title', array(
        '!title' => $old_link['link_title'],
      ));
      $link['plid'] = $old_link['plid'];
      $link['menu_name'] = $old_link['menu_name'];
      $link['weight'] = $old_link['weight'];
      $link['module'] = $old_link['module'];
      return $link;
    }
  }
  return NULL;
}