Change target on links in embed forum
Is there any way to change target links (target = "_blank") when using embed forum? (using Vanilla 2.0.18.10)
I'm using CLEditor, but I didn't found a way to change the target links posted with this editor. Would be ideal to only add target="_blank" in the links on Vanilla iframe and not the entire page. (I'm using Drupal).
I'm missing something? I found similar threads but no real solution to this issue.
Thanks!
Best Answers
-
vrijvlinder MVP
Can you specify which links you want to open in new window ?
You can add some jquery to the default.master.php or tpl and make certain links open in a new window.
for example here I made these for my own setup pick the ones you want or need:
<script type="text/javascript"> $(document).ready(function() { $('.MessageList a').attr('target', '_blank'); $("#Foot #Menu a").attr("target", '_blank'); $(".AptAdImg a").attr("target", '_blank'); $(".Attachment a").attr("target", '_blank'); $(".Meta a").attr("target", '_self'); $('#Foot #Menu li:last > a').attr("target", '_blank'); $('#Menu ul li:last-child > a').popup(); $('#Foot #Menu li.Messagelink a').popup(); $('#Foot #Menu li:last > a').popup(); $('span.onebit_mp3 a').attr("target", '_blank'); $("a.ReactButton.Quote.Visible").attr("target", '_self'); }); </script>
8 -
vrijvlinder MVP
you need to add the javascript between {literal}script goes here {/literal} tags if your master is a tpl
5
Answers
Can you specify which links you want to open in new window ?
You can add some jquery to the default.master.php or tpl and make certain links open in a new window.
for example here I made these for my own setup pick the ones you want or need:
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Tried editing: vanilla/themes/EmbedFriendly/views/default.master.tpl but as soon I started the jquery code $(document).ready(function() it throws an error 500. Adding normal Javascript code doesn't return error 500.
I need to add the jquery libraries on this template?
you need to add the javascript between {literal}script goes here {/literal} tags if your master is a tpl
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Thank you so much, that worked perfect!
You are very Welcome !
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
@hgtonight or @UnderDog could you please move this to the Tutorials ?
Thanks
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Does this apply to embedded comments? I've modified default.master.tpl and links have different targets in forum posts, but on the embedded comments, things still open within the iframe instead of on _top. If not, where can I modify attributes for Vanilla Embedded Comments for WordPress?
The same way , you just need to find the classes for the links you want to apply this to.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
is there a way to set all anchors to _self, without having to identify each one? also I added the javascript above and it gave me an error "Something has gone wrong."
yes by simply using a and a:link. That will make all links open in the same window
$('a').attr('target', '_self');
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
I tried adding the code under the head tag in the default.master.tpl, for my theme but I get a "Something has gone wrong." error page.
{literal}
$(document).ready(function() { $('a').attr('target', '_self'); });{/literal}
You need to use the javascript tags
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
tried both $('a').attr('target', '_self'); and $("a.Title").attr("target", '_self'); still won't override it. do you know where at in the coding I can manually remove the target? This is for the Title name of the categories
try this
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
for the Categories title link
.DataList .ItemContent.Category a.Title
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌