- Create custom module Replace mymdulename with your module name.
- implement hook menu to add "Menu local task" which let your menu
item to show along with view, edit ..
- page call back to add the
redirect rule, in below example I am redirecting to google.com, you
can add a check according to node and add redirection rule.
- access callback ensures this menu tabs gets attached to nodes for article
content type.
/** * Implements hook_menu(). */
function mymodulename_menu() {
$items = array();
$items['node/%node/movies'] = array(
'title' => 'Movies',
'page callback' => 'mymodulename_redirect',
'page arguments' => array('node', 1),
'access callback' => 'mymodulename_content_type_check',
'access arguments' => array(1),
'type' => MENU_LOCAL_TASK,
'weight' => 100,
);
return $items;
}
/**
* Access callback
*/
function mymodulename_content_type_check($node) {
if ($node->type != 'article') {
return FALSE;
}
return TRUE;
}
function mymodulename_redirect($node) {
dpm($node);
$url = "http://www.google.com";
drupal_goto($url, array('external' => TRUE));
}
Update
to open the external link in new tab use jquery to add '_blank' attribute
in your custom
jQuery('.tabs a').attr("target","_blank");
Remember to pick unique classes instead of ".tab" to avoid having this behaviour to all tabs.