Hi there,
Is there anyway in which I can force the Marinelli banner url links to open up in a new window - target="_blank" ?
Many thanks in advance for your help
Maxplay

CommentFileSizeAuthor
#8 patch-marinelli.png12.08 KBPremanshu
#6 1122524-5.patch512 bytesdjsagar
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maxplay’s picture

Title: Banner url links ind new window "target="_blank" » Banner url links in new window "target="_blank"
Deepika.chavan’s picture

Hi,
I tried the same thing on my local site.
1. I added following line in template.php after include_once('logics/banners.inc'); line:

   drupal_add_js(drupal_get_path('theme', 'marinelli') . '/myjs.js');

2. Added following code in myjs.js file (path- /themes/marinelli/myjs.js):

jQuery(document).ready(function($){
	$("#header-images a").attr('target', '_blank');
});

3. Cleared cached data.(here-'admin/config/development/performance').

Rgrds,

Deepika chavan.

maxplay’s picture

Fantastic Deepika - it worked :-)

Just one little comment for other users:
I am using Drupal 7 together with the Marinelli 7.x template.
In this version, the JS file which has to be modified is as follows:

/themes/marinelli/js/marinelli_marinelli.js

I also modified the template.php script to address this location:
drupal_add_js(drupal_get_path('theme', 'marinelli') . '/js/marinelli_marinelli.js');

Otherwise just do what Deepika suggested and it works.

I hope this all makes sence - otherwise please correct me.

Many thanks again Deepika

Maxplay

CarlosSR’s picture

Issue summary: View changes

(five years later)
Fantastic! it works perfectly.

But in my carousel banner there are external and internal links.
I wish that external links open a new tab, and internal do not.

How could I do it?

Thanks for helping!

djsagar’s picture

Status: Active » Reviewed & tested by the community

Hi Deepika,

Code is working which you are sharing just created patch for your code in 7.x-4.x Version and change the status for knowledge who had facing this issue.
With help of this page or status change they can resolved there issue.

Thanks!

djsagar’s picture

FileSize
512 bytes

Patch for 7.x-4.x Version.

djsagar’s picture

Status: Reviewed & tested by the community » Needs review
Premanshu’s picture

Assigned: maxplay » Unassigned
Status: Needs review » Reviewed & tested by the community
FileSize
12.08 KB

This patch applies cleanly.

  • gaurav.kapoor committed 2a30044 on 7.x-4.x authored by djsagar
    Issue #1122524 by djsagar, Premanshu: Banner url links in new window "...
gaurav.kapoor’s picture

Status: Reviewed & tested by the community » Fixed
gaurav.kapoor’s picture

By default, there will be a link opening in a new tab. In case someone has internal links as well, they will have to add appropriate JS code.

Deepika.chavan’s picture

Hi,

Below js code may help to open only external links in new tab.

  var img_url = $("#header-images a").attr('href');
    if (img_url.indexOf("http://") == 0 || img_url.indexOf("https://") == 0) {
        $("#header-images a").attr('target', '_blank');
    }else{
       $("#header-images a").attr('target', '_top'); 
   }

Regards,
Deepika

Status: Fixed » Closed (fixed)

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