how can i add a target="_blank" to the go/test link in my Navigation menu (and Primary/Secondary Links), if this link is redirecting to an external site? If this is possible this should be a configurable per go-URL option...

Any idea?

Comments

jredding’s picture

I don't think this is an issue for the Go two module, it handles target=_blank just fine. The primary and secondary links, however, don't have an option for them.

I think this issue needs to be moved over to the menu module/core

hass’s picture

Project: Go - url redirects » Drupal core
Version: 4.7.x-1.x-dev » 4.7.4
Component: Code » menu system

ok

killes@www.drop.org’s picture

Version: 4.7.4 » x.y.z

new features go into devel version.

keesje’s picture

Version: x.y.z » 4.7.4

Put this in your template.php

function phptemplate_menu_item_link($item, $link_item) {
    if (substr($link_item['path'], 0, 4) == 'http') {
        return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description'], 'target' => '_blank') : array('target' => '_blank'));
    }elseif (stripos($link_item['path'], '_blank') > 0){
        $link_item['path'] = str_replace('_blank','',$link_item['path']);
        return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description'], 'target' => '_blank') : array('target' => '_blank'));
    }else {
        return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description']) : array());
    }
}

Explaination: Filters all external links (starting with http), and links where path contains _blank and add target="_blank" property.
Just add _blank to the path of the node and you're ok.

Thanks to trantt for his post.

Regards.

Maatwerk in webapplicaties

Paul Natsuo Kishimoto’s picture

Version: 4.7.4 » 4.7.x-dev

killes was right, but let's set it to 4.7.x-dev.

Is this fixed? If so, please close the issue.

Zen’s picture

Version: 4.7.x-dev » 6.x-dev
Status: Active » Closed (duplicate)
trantt’s picture

can someone help us with version 5 syntax? return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description'], 'target' => '_blank') : array('target' => '_blank')); is not working on version 5

coderintherye’s picture

Did you try 'target' => 'blank' or in other words taking out the underscore? That works for me in D5. For a more thorough look at this problem take a look at my post here about it http://www.nowarninglabel.com/home/node/13

ranj.sarraj’s picture

andrewmacpherson’s picture

Issue summary: View changes

Some contrib modules provide this:

Bear in mind there is an accessibility issue with target=_blank. F22: Failure of Success Criterion 3.2.5 due to opening windows that are not requested by the user.