I want to add an extra tab menu item to article node type.

I mean a new menu item beside view, edit and other tabs only in article node.

but this tab menu item has external link to another site and it's target is _blank (to open destination in new window)

what is your solution for my issue?

  • I believe with hook_menu and title callback
    – Roni Gal
    Mar 29, 2014 at 22:22

1 Answer 1

  1. Create custom module Replace mymdulename with your module name.
  2. implement hook menu to add "Menu local task" which let your menu item to show along with view, edit ..
  3. 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.
  4. 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) {
  $url = "http://www.google.com";
  drupal_goto($url, array('external' => TRUE));


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.