Is there a way to control if an ad opens in a new window or the current window for individual ads?

CommentFileSizeAuthor
#3 ad_image_clickthru_target.patch4.66 KBarcane

Comments

arcane’s picture

I know this is a global setting, but just wanted to check if I missed anything. My desired behavior is for internal links to open in the same browser window and for external links to open in a new browser window.

arcane’s picture

I located the code for Image Ad, so I'll see if I can make the changes and perhaps roll a patch.

arcane’s picture

StatusFileSize
new4.66 KB

I've created a patch that includes a dropdown field for Click-target for Image Ads. It includes the update hook to add the extra column in the database.
It uses the same options as the Global Settings for the target and generates the same html code using the existing onclick code.

To test the patch, download and run from ad/image directory. Afterwards, run update.php and then create a new image advertisement.

The patch was generated against version = "6.x-2.2".

marcinsdance’s picture

Thanks a lot, I've used this on our site and it works great! Exactly what I needed.

arcane’s picture

There is a flaw in this patch in that it only supports Safari browser. There is a quick fix I will post and update the patch.

ericpai’s picture

I have the patch installed, but when attaching an Ad image I get this output after clicking the "Attach" button:

{ "status": true, "data": "\x3cdiv class=\"messages error\"\x3e\n \x3cul\x3e\n \x3cli\x3ewarning: Parameter 2 to ad_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to ad_channel_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to ad_owners_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to ad_weight_probability_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to audio_attach_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to audio_feeds_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to audio_getid3_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to audio_images_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to video_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to ckeditor_swf_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to xmlsitemap_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3cli\x3ewarning: Parameter 2 to xmlsitemap_node_form_alter() expected to be a reference, value given in C:\\xampp\\htdocs\\drupal_shared\\html\\includes\\common.inc on line 2883.\x3c/li\x3e\n \x3c/ul\x3e\n\x3c/div\x3e\n\x3ctable id=\"upload-attachments\" class=\"sticky-enabled\"\x3e\n \x3cthead\x3e\x3ctr\x3e\x3cth\x3e\x3c/th\x3e\x3cth\x3eDelete\x3c/th\x3e\x3cth\x3eList\x3c/th\x3e\x3cth\x3eDescription\x3c/th\x3e\x3cth\x3eWeight\x3c/th\x3e\x3cth\x3eSize\x3c/th\x3e \x3c/tr\x3e\x3c/thead\x3e\n\x3ctbody\x3e\n \x3ctr class=\"draggable odd\"\x3e\x3ctd\x3e\x3c/td\x3e\x3ctd\x3e\x3cdiv class=\"form-item\" id=\"edit-files-307-remove-wrapper\"\x3e\n \x3cinput type=\"checkbox\" name=\"files[307][remove]\" id=\"edit-files-307-remove\" value=\"1\" class=\"form-checkbox\" /\x3e\n\x3c/div\x3e\n\x3c/td\x3e\x3ctd\x3e\x3cdiv class=\"form-item\" id=\"edit-files-307-list-wrapper\"\x3e\n \x3cinput type=\"checkbox\" name=\"files[307][list]\" id=\"edit-files-307-list\" value=\"1\" checked=\"checked\" class=\"form-checkbox\" /\x3e\n\x3c/div\x3e\n\x3c/td\x3e\x3ctd\x3e\x3cdiv class=\"form-item\" id=\"edit-files-307-description-wrapper\"\x3e\n \x3cinput type=\"text\" maxlength=\"256\" name=\"files[307][description]\" id=\"edit-files-307-description\" size=\"60\" value=\"ad_125x125_2_blue.jpg\" class=\"form-text\" /\x3e\n \x3cdiv class=\"description\"\x3e\x3csmall\x3ehttp://mysite.com/sites/mysite.com/files/ad_125x125_2_blue_2.jpg\x3c/small\x3e\x3c/div\x3e\n\x3c/div\x3e\n\x3c/td\x3e\x3ctd\x3e\x3cdiv class=\"form-item\" id=\"edit-files-307-weight-wrapper\"\x3e\n \x3cselect name=\"files[307][weight]\" class=\"form-select upload-weight\" id=\"edit-files-307-weight\" \x3e\x3coption value=\"-1\"\x3e-1\x3c/option\x3e\x3coption value=\"0\" selected=\"selected\"\x3e0\x3c/option\x3e\x3coption value=\"1\"\x3e1\x3c/option\x3e\x3c/select\x3e\n\x3c/div\x3e\n\x3c/td\x3e\x3ctd\x3e2.8 KB\x3c/td\x3e \x3c/tr\x3e\n\x3c/tbody\x3e\n\x3c/table\x3e\n\x3cdiv class=\"form-item\" id=\"edit-upload-wrapper\"\x3e\n \x3clabel for=\"edit-upload\"\x3eAttach new file: \x3c/label\x3e\n \x3cinput type=\"file\" name=\"files[upload]\" class=\"form-file\" id=\"edit-upload\" size=\"40\" /\x3e\n\n \x3cdiv class=\"description\"\x3eThe maximum upload size is \x3cem\x3e100 MB\x3c/em\x3e. Only files with the following extensions may be uploaded: \x3cem\x3ejpg jpeg gif png txt html doc xls pdf ppt pps avi mpeg mpg mov rm m4v flv wmv 3gp mp4 dir dcr ogg\x3c/em\x3e. \x3c/div\x3e\n\x3c/div\x3e\n\x3cinput type=\"submit\" name=\"attach\" id=\"edit-attach\" value=\"Attach\" class=\"form-submit\" /\x3e\n" }

Any idea why this is happening?

thanks

ericpai’s picture

It was a problem with the field name of "target". I changed it to "target_window" and it worked.

  $form['ad_image']['<strong>target_window</strong>'] = array(
    '#type' => 'select',
    '#title' => 'Click-through target',
    '#required' => TRUE,
    '#options' => array(
        '_blank' => 'new browser window',
    	'_self' => 'same browser window and frame',
        '_parent' => 'parent frame',
        '_top' => 'same browser window, removing all frames',
     ),
     '#default_value' => isset($node->target_window) ? $node->target_window: variable_get('ad_link_target', '_blank'),
     '#multiple_toggle' => '0',
  );

Thank you for the patch!!

lrwebks’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 6 is EOL and no longer supported. Closing this as outdated for that reason. Thanks for your contribution!