From 668c1cfbfd6b62ae6b4dc68cf30ea2c6a5611f4d Mon Sep 17 00:00:00 2001
From: NitinSP <nitin.patil@clariontechnologies.co.in>
Date: Thu, 5 May 2016 19:19:20 +0530
Subject: [PATCH] Issue #2366021 NitinSP: Open link in a new tab or window

---
 url.module | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/url.module b/url.module
index 19cb1b8..4e3ae13 100644
--- a/url.module
+++ b/url.module
@@ -236,6 +236,7 @@ function url_field_formatter_info() {
     'settings' => array(
       'trim_length' => 80,
       'nofollow' => FALSE,
+      'target_blank' => FALSE,
     ),
   );
 
@@ -263,6 +264,11 @@ function url_field_formatter_settings_form($field, $instance, $view_mode, $form,
     '#title' => t('Add rel="nofollow" to all links'),
     '#default_value' => $settings['nofollow'],
   );
+  $element['target_blank'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Add target="_blank" to all links'),
+    '#default_value' => $settings['target_blank'],
+  );
 
   return $element;
 }
@@ -286,6 +292,9 @@ function url_field_formatter_settings_summary($field, $instance, $view_mode) {
   if (!empty($settings['nofollow'])) {
     $summary[] = t('Add rel="nofollow"');
   }
+  if (!empty($settings['target_blank'])) {
+    $summary[] = t('Add target="_blank"');
+  }
 
   return implode('<br />', $summary);
 }
@@ -303,6 +312,9 @@ function url_field_formatter_prepare_view($entity_type, $entities, $field, $inst
       if (!empty($settings['nofollow'])) {
         $item['options']['attributes']['rel'] = 'nofollow';
       }
+      if (!empty($settings['target_blank'])) {
+	       $item['options']['attributes']['target'] = '_blank';
+      }
     }
   }
 }
-- 
1.9.4.msysgit.1

