I'm using the ad system to promote my own pages and sometimes I'd like it to open in the same window. Of course there are still "real ads" so these will need to open in new windows. Is it possible to add an option to disable open in new window or select which link behavior you want.
I am specifically talking about ad_images (image ads), though I suppose it can apply elsewhere too
I figure an alternative would be to do HTML Ad and input the HTML in myself
THANKS!
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | ad.field_open_in_new_window-498250-9.patch | 568 bytes | lucashodge |
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.