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!

Comments

rschaft’s picture

I'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

jeremy’s picture

sailey’s picture

Title: Ad Image: Option to specify which click-through links open new tab or open in same page » Ad Image: is there an option for an image to be opened in same page when clicked on it?
Version: 6.x-2.x-dev » 7.x-1.x-dev
Category: feature » support
Priority: Normal » Major
Status: Closed (duplicate) » Active
iamsuperan’s picture

Issue summary: View changes

Hello,

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.

rohitrajputsahab’s picture

Add this code in your custom js file

//node-ad
jQuery('.node-ad a').attr('target', '_blank');

rohitrajputsahab’s picture

<?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".

rohitrajputsahab’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

lucashodge’s picture

StatusFileSize
new568 bytes

Attached a patch for this to open in a new window.