We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

click link in blog want it to open in new page | Forum

Topic location: Forum home » Support » General Questions
Derek
Derek Apr 27 '16

hello I looked around cant find any info. what I would like is to force new page to open when links are clicked in blogs news groups forums ect. I know in blogs there is a box for users to choose. lots uncheck it so takes you out my site to there webpage . any help would be nice .. thank you



The Forum post is edited by Derek Apr 29 '16
Darryl B Leader
Darryl B Apr 30 '16
Try this plugin in the store for free "external linker". I just gave it a try on my test site. It seems to work well. I had some other js code in the post, but found that it interfered with the chat window.

http://www.oxwall.org/store/item/291
The Forum post is edited by Darryl B May 1 '16
Darryl B Leader
Darryl B May 21 '16
Found an issue with the "External Linker" plugin. It doesn't play well with the "Add New" links. I found a js code that works good except for two links, for me anyway, in the "Add New" links. They both have javascript links with target="_blank". They both open a blank page. If I edit the code in inspect element, and remove the target="-blank" they open fine. I'm trying to search for a work around for this type of link, but no luck so far.
Darryl B Leader
Darryl B May 21 '16
I think I have found a successful script that works "even all of the add new links". Everything on the site seems to work, and external links open in a new tab.

I just put this in admin / settings / page settings / body

<script type="text/javascript">
$(document).ready(function(){
 var isInternalLink = new RegExp('/' + window.location.host + '/');           
 var h = window.location.host.toLowerCase();
$("a[href^='http']:not([href^='" + h + "']):not([href^='http://www." + h + "']):not([href^='mailto:']),a[href$='.pdf']").attr("target", "_blank");
   
});
</script>

The Forum post is edited by Darryl B Jun 2 '16
dave Leader
dave May 21 '16
Darryl, 


you might consider wrapping that in 
{literal}
{/literal}
i don't know if you need to in that section but i always wrap my scripts in that within the html files so it might be the same :)

Darryl B Leader
Darryl B May 21 '16
It was working as is, but I put your suggestion in as well. Everything still works well.
dave Leader
dave May 21 '16
Great, its just that smarty at times can be fussy, and i dont know how that section you posted the code in is parsed or filtered which is why i am not sure if needed or not. 


http://www.smarty.net/docsv2/en/language.function.literal


I just know that in the html file itself its always best to wrap it.  Its probably just fine your good at what you know buddy.  Its just an extra precaution i guess. :)

Darryl B Leader
Darryl B May 21 '16
I looked the literal tag up. I had seen it before, but haven't really looked to see what it's for. Guess it is good to use it around scripts, just in case.
Darryl B Leader
Darryl B Jun 2 '16
I just noticed that the {literal} tags were displaying as text at the bottom of the page. Didn't really notice it until now, so I took them out, and re-posted the script above without them.
dave Leader
dave Jun 2 '16
strange... but glad you caught that i didnt notice that either
Darryl B Leader
Darryl B Jun 2 '16
It appears from a little more reading on them that placement of the tags is important. Maybe they respond differently when they aren't local. Several examples used the tags within the script, and not just encasing the script with them.
dave Leader
dave Jun 2 '16
sometimes its {literal} which is smarty i think and the normal is <literal> cause i have it on a test page now as <literal> and its not showing, interesting