Is it possible to make all service links to be open at new window?

Ectar - June 21, 2007 - 22:25
Project:Service links
Version:5.x-1.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:patch (code needs review)
Description

instead same window... I don't want to move my visitors away from the site.

#1

apsivam - June 22, 2007 - 04:27
Status:active» postponed

we will plan something for this in the next release

#2

TfR75 - August 14, 2007 - 12:11

that would be cool!

#3

Aaron Stanush - October 11, 2007 - 17:34

This would be a fantastic addition. Could be simple as a check box on the module configuration page.

#4

adamcarsonb - January 15, 2008 - 20:53
Category:support request» feature request

Here's how I modified this module to open each link in a new window.
In service_links.module, I modified the lines ending in //ACB. I added a 'target' parameter in the attributes array for the link. Hope this helps, and I hope I've done it right.

if ($nodelink) {
switch (variable_get('service_links_style', 1)) {
case 1:
$link = array(
'title' => $text,
'href' => $url,
'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank') //ACB
);
break;
case 2:
$link = array(
'title' => '',
'href' => $url,
'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank'), //ACB
'html' => TRUE
);
break;
case 3:
$link = array(
'title' => ' '. $text,
'href' => $url,
'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank'), //ACB
'html' => TRUE
);
break;
}
}

AttachmentSize
service_links.zip3.48 KB

#5

matt@antinomia - March 12, 2008 - 21:28
Version:5.x-1.0» 5.x-1.x-dev
Status:postponed» patch (code needs review)

Attached is a patch that makes use of the external links filter module to force service links to open in a new window (applies target="_blank" via jQuery to ensure W3C compliancy -- target="_blank" is not compliant. Please review.

AttachmentSize
external_service_links.patch2.61 KB

#6

wesku - April 3, 2008 - 20:34

While waiting for this feature you can override theme_service_links_build_link in your own theme. This means you don't have to hack the module at all. With phptemplate and current 5.x release of Service Links add this to your template.php:

<?php
function phptemplate_service_links_build_link($text, $url, $title, $image, $nodelink) {
  global
$base_path;

  if (
$nodelink) {
    switch (
variable_get('service_links_style', 1)) {
      case
1:
       
$link = array(
         
'title' => $text,
         
'href' => $url,
         
'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank')
        );
        break;
      case
2:
       
$link = array(
         
'title' => '<img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" />',
         
'href' => $url,
         
'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank'),
         
'html' => TRUE
       
);
        break;
      case
3:
       
$link = array(
         
'title' => '<img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /> '. $text,
         
'href' => $url,
         
'attributes' => array('title' => $title, 'rel' => 'nofollow', 'target' => '_blank'),
         
'html' => TRUE
       
);
        break;
    }
  }
  else {
    switch (
variable_get('service_links_style', 1)) {
      case
1:
       
$link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow" target="_blank">'. $text .'</a>';
        break;
      case
2:
       
$link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow" target="_blank"><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /></a>';
        break;
      case
3:
       
$link = '<a href="'. check_url($url) .'" title="'. $title .'" rel="nofollow" target="_blank"><img src="'. $base_path . drupal_get_path('module', 'service_links') .'/'. $image .'" alt="'. $text .'" /> '. $text .'</a>';
        break;
    }
  }

  return
$link;
}
?>

#7

marlandc - July 22, 2008 - 22:42

I want to follow up with #4, this worked for me. The bookmarks open up in a new window. Thanks!

#5 and #6 may work as well, I just applied the first answer.

 
 

Drupal is a registered trademark of Dries Buytaert.