Posted by hass on October 16, 2006 at 6:16pm
Jump to:
| Project: | Drupal core |
| Version: | 6.x-dev |
| Component: | menu system |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (duplicate) |
Issue Summary
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
#1
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
#2
ok
#3
new features go into devel version.
#4
Put this in your template.php
<?phpfunction 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
#5
killes was right, but let's set it to 4.7.x-dev.
Is this fixed? If so, please close the issue.
#6
Duplicate of http://drupal.org/node/102669
#7
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
#8
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
#9
Here is the solution ;-)
http://drupal.org/node/335853#comment-2278626