Closed (fixed)
Project:
Advertisement
Version:
7.x-1.x-dev
Component:
ad_image module
Priority:
Major
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
22 Jun 2009 at 02:28 UTC
Updated:
16 Jul 2019 at 09:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
rschaft commentedI'm facing the same problem. I have an ad for an external site (to be opened in a new window) and to a menu on the Drupal site. Can this be done?
Greetings,
Ruud
Comment #2
jeremy commentedDuplicates:
#230250: New window depending on external or internal link
#166362: a patch to set particular groups to _self and others to _blank
Comment #3
sailey commentedComment #4
iamsuperan commentedHello,
Just wondering why this is marked as a duplicate of https://www.drupal.org/node/230250 (drupal 6) when this issue version is for drupal 7.
Comment #5
rohitrajputsahab commentedAdd this code in your custom js file
//node-ad
jQuery('.node-ad a').attr('target', '_blank');
Comment #6
rohitrajputsahab commented<?php
/**
* Implements hook_field_formatter_info().
*/
function ad_field_formatter_info() {
// A simple formatter which links the image to the destination URLs, if any.
$formatters = array(
'ad_image' => array(
'label' => t('Ad Image'),
'field types' => array('image'),
),
);
return $formatters;
}
/**
* Implements hook_field_formatter_view().
*/
function ad_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
$destination = ad_get_destination($entity);
if (!empty($destination)) {
// Also add placeholders for impression id.
$uri = 'ad/click/' . $entity->nid . '/' . AD_IMPRESSION_ID_PLACEHOLDER;
}
else {
$uri = '';
}
foreach ($items as $delta => $item) {
$element[$delta] = array(
// Reuse theme_image_formatter().
'#theme' => 'image_formatter',
'#item' => $item,
'#image_style' => '',
//'#path' => isset($uri) ? array('path' => $uri) : '',
'#path' => array('path' => $uri,
'options' => array(
'attributes' => array(
'target' => '_blank'
)
)
),
);
}
return $element;
}
copy this code and replace into the "ad/ad.field.inc".
Comment #7
rohitrajputsahab commentedComment #9
lucashodge commentedAttached a patch for this to open in a new window.