Support Forum

Please note that this forum is only available to you in read only mode. In order to contribute to this conversation you will need to renew your subscription.

zentools2

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Hi Paul,

Is there a way, with the hero slideshow in zentools2, to have a manual link open in a new browser window?

I tried just adding target="blank" next to the external url that I entered into the manual links box but that didn't work (got 404).

I also tried adding my link to "Link A" in the "Images and Links" tab of the Article editor set to open in new window but that didn't work either.

Any magic up your sleeve?

Thanks,

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
Last Edit: 3 years 9 months ago by joanne721.
The administrator has disabled public write access.
I found a couple of scripts that force all external links to open in a new browser window (which would be fine). I added them to Settings > Custom snippets > After Opening Head tag -- in the template manager -- but they give me errors. They look like this:

/**
* Open all external links in a new window
*/
jQuery(document).ready(function($) {
$('a')
.filter('[href^="http"], [href^="//"]')
.not('[href*="' + window.location.host + '"]')
.attr('rel', 'noopener noreferrer')
.attr('target', '_blank');
});



// vanilla JavaScript
var links = document.links;

for (var i = 0, linksLength = links.length; i < linksLength; i++) {
if (links.hostname != window.location.hostname) {
links.target = '_blank';
}
}

// or in jQuery
$(document.links).filter(function() {
return this.hostname != window.location.hostname;
}).attr('target', '_blank');

Am I putting them in the right place?

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Joanne,

I'll need to check on this with the developer tomorrow

As I don't know

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Thanks!
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Joanne,

Do you have a link for the site so I can see the layout you've got?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Hi Paul,

I'm working on site here: pinatel721.com/massage/

The first slide in the slideshow is linked to a youtube video -- I was wondering how to make it open in a new window or tab.

I found some code that is supposed to force all external links open in new window but don't know where to put it or whether it is the right format, etc.

I included the code earlier in this thread.

Thanks,

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Joanne,

Sorry for the delay on a reply from us

Was thinking about this - with new window it doesn't always work as users can have their browsers set up differently e.g. load in new tab, load in new window or not work at all

I know one of my client has it disabled which caused me no end of problems till I realised
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Are you wanting to try with a video on each tab of the module?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
No, I just wanted to have the external link open in a new window (or tab) on the first slide that links to YouTube. I thought a way around the problem (since I don't see the option in the extension) would be to include a script that forced all external links to open in a new tab (or window) but I couldn't get the script to work. Not sure why.

Can you suggest another way?

If someone has disabled target=blank in their browsers preferences, I'm not really worried about designing for them.

Thanks!

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Paul,

Here is one of the code snippets I found online that won't play nice with the template. I added it to Settings > Custom snippets > After Opening Head tag

/**
* Open all external links in a new window
*/
jQuery(document).ready(function($) {
$('a')
.filter('[href^="http"], [href^="//"]')
.not('[href*="' + window.location.host + '"]')
.attr('rel', 'noopener noreferrer')
.attr('target', '_blank');
});

Do you know if this is correct?

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Here's another code snippet I found but when I paste it into the Cod Snippet box --either before head or after head tag -- it just displays an error on the front end.

$('A[rel='external']').click( function() {window.open( $(this).attr('href') );return false;});

Am I putting it in the wrong place?

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Joanne,

It is more of a hacked zentools2 version rather than adding additional js

I can't get it to work at the moment but will try again tomorrow

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Thanks, Paul.

But it might still be good to know why I can't add scripts to the template. I have tried 4-5 scripts that all are supposed to force external links to open in a new tab/window.

That seems like a good solution to me.

But no matter where I put the snippet (before/after head or body tags) it just shows up on the top of the screen in the front end.

What am I missing?

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Again,

I'm scheduled to go live with this site this weekend. It's not a deal-breaker but I'd really like to get the template to accept my code snippets so I can force external links to open in a new window. I'm not sure if it's the snippets or the template that's not working.

Should I open a ticket?

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi joanne,

Where are you getting these scripts from?

Can you add a link or two?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Here are a few places I found. Apparently there are lots of ways to do this.

css-tricks.com/snippets/jquery/open-external-links-in-new-window/

gist.github.com/CrocoDillon/7989214

www.joomshaper.com/forums/code-to-force-all-external-links-to-open-on-another-window

I have also attached the codes I've tried. All just show up on the top of the home page.

Joanne
Attachments:
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
So I figured out why all the scripts were displaying as an error! I wasn't adding the tags!

Now that I have that sorted, I tried all the snippets but none of them work.

This would make a great plugin for Joomla. There are a few for Wordpress but I couldn't find anything for Joomla.

Anyway, thanks for all the help.

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Sorry I should have mentioned that in my previous post

With the readmore you have you can use the content link option to use the new window option but I'm assuming you want the video when clicked to open the video?

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.
Yeah, the link does open the video now just in the same window. I can't use the readmore option in zentools because that will make ALL the links open in a new window when I only want the first one to do that.

I'm disappointed that none of the many, many scripts out there that claim to solve this very problem don't work with either Joomla or the template.

I'm thinking of getting someone to write a plugin for this!

Joanne
  • joanne721's Avatar
  • joanne721
  • 6 Month Developer
  • 285 posts
  • Karma: 0
The administrator has disabled public write access.
Hi Joanne,

I think the scripts are more likely to work with joomla article content

The problem with scripts is how extensions work as the scripts are already processed

It is made even more complicated with just the one slide working like this

There could be a couple of things you could try but I'm really not sure if they'd work

Cheers
Paul
  • manh's Avatar
  • manh
  • Moderator
  • 45248 posts
  • 2106 Thanks
  • Karma: 603
The administrator has disabled public write access.

zentoolsIf you use Zentools please post a review at the Joomla! Extensions Directory.

Happy Campers