By BrendanHodge on
Is there a way to globally set all links off the site to open _blank, or to do so within a area of the site, such as the forums or on all comments?
Is there a way to globally set all links off the site to open _blank, or to do so within a area of the site, such as the forums or on all comments?
Comments
template.php
open _blank from a menu:
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'));
}
else {
return l($item['title'], $link_item['path'], isset($item['description']) ? array('title' => $item['description']) : array());
}
}
Other than that, I don't have an answer for your question (forum, comment, etc...).
Hmmm. And unfortunately,
Hmmm. And unfortunately, it's mainly the comments, forums and blogs that I'm trying to do this to. Idea being, that when people post links to outside content, we don't necessarily want to lose them from the main site while they follow that.
Drupal 5: open _blank from a menu?? Need help on logic
Can someone help me with version 5 logic? The below logic doesn't work:
function phptemplate_menu_item_link($item, $link_item) {
if (substr($link_item['path'], 0, 4) == 'http')
{
return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description'], 'target' => '_blank') : array('target' => '_blank'), isset($item['query']) ? $item['query'] : NULL);
}
else
{
return l($item['title'], $link_item['path'], !empty($item['description']) ? array('title' => $item['description']) : array(), isset($item['query']) ? $item['query'] : NULL);
}
}
Here is the warning message that I received:
warning: Cannot modify header information - headers already sent by (output started at /homepages/24/d184208487/htdocs/drupal5/themes/garlandrtl/template.php:1) in /homepages/24/d184208487/htdocs/drupal5/includes/common.inc on line 311.
Thanks
need help on function phptemplate_menu_item_link
can someone please help me with version 5 logic? I would like to add target="_blank" to any url tag where the first 4 characters are http.
Thanks
'headers already sent by' warning - problem resolution
The reason why you get the warning message is probably because you have a leading blank line in template.php before the php opening tag.
Eliminate all blank lines outside the
...and it is supposed to work fine...A possible work around...
I am doing my first Drupal and thought this was indeed bad but then ... With version 5 I did the following. May not be elegant but seems to work.
I created a block (full html) with the following content
As I said this may not work for everyone but gets me going.
Oh yes, I am using Bluebreeze. I don't know enough about Drupal to say it will work with all themes.
Richard
Launch http:// on a new page
Currently I'm using the custom block as well but however, there will be time when I need to mix the regular menu item with a _blank type of menu item. As I mentioned before, the new drupal 5 structure is little bit different from the previous version and therefore, I've no idea what to do.
good idea
Yes, i agree.. and just doing some googling now.. but the menu module should have a _blank option with it
also looking at code to see if it is an easily doable patch...
of course the alternative is to create a CCK type with link fields and then use those to create menu items - those fields of course have _blank option
but.. still.. it should be option with menu module
Peter Lindstrom
LiquidCMS - Content Management Solution Experts
Peter Lindstrom
LiquidCMS - Content Solution Experts
external link module
this module will open an external url from a different tab/browser.