Open links in new tabs

Support for PhpBB3. Post here to get help with any phpBB3 related issue here
There is no support here! Only Read Access!
Forum rules
In order the get any support, you will have to do following:
1. Use a describing title!
2. Describe your problem and what happened when the problem occured
3. Tell us what version of phpBB3 you are currently using.
Else your topic may be ignored or locked!
Locked
alphahusky
BBCoder I
BBCoder I
Posts: 1
Joined: 08 Mar 2010, 13:37

Open links in new tabs

Post by alphahusky »

I made two mods. Open links in new tab bbcode and open links in new tab non-bbcode. I went to reference them today, and they're gone... AHHHH! Help!
I even had to re-register.. aye aye aye! 8-) :o
User avatar
Stoker
Site Admin
Site Admin
Posts: 3536
Joined: 12 May 2008, 23:26
BBCodes: 239
Favourite BBCode: Anipro
Favourite MOD: PrettyPhoto
Location: Denmark
Contact:

Re: Open links in new tabs

Post by Stoker »

Found some of it here:
Alphahusky » 06 Jun 2009, 02:31 wrote:I know there is a post already about opening links in a new tab, but is is only for the URL bbcode and does not work if someone just types in the the web address without the URL bbcode...

This way will will open links in new tabs without the url bbcode....

(!!PLEASE SEE NEXT POST BEFORE USING THIS CODE. YOU MAY WANT TO USE THE NEXT SET INSTEAD.!! Thank you!)

Open: /includes/functions_content.php
Find:

Code: Select all

$html	= "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";
Replace with:

Code: Select all

$html	= "$whitespace<!-- $tag --><a$class href=\"$url\" onclick=\"window.open(this.href);return false;\">$text</a><!-- $tag -->$append";
You may need to Purge the cache after doing this....

That's it!
Alphahusky » 06 Jun 2009, 02:50 wrote:Oops... Found a couple of hiccups...

1. Email link opens new tab
2. local links are opened in new tab as well...

I just fixed them though....

I will leave the code above unchanged in case people want it that way.. elsewise, here is the fixed code that will only open external links in new tabs and leave local links and email alone..

Find:

Code: Select all

$html   = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";
Or find (If you used my above code first)

Code: Select all

$html   = "$whitespace<!-- $tag --><a$class href=\"$url\" onclick=\"window.open(this.href);return false;\">$text</a><!-- $tag -->$append";
Replace with:

Code: Select all

$DoNormal = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append"; 
	
        if ($type == MAGIC_URL_EMAIL)
        {
            $html    = $DoNormal;
        }
		elseif ($type == MAGIC_URL_LOCAL)
		{
			$html    = $DoNormal;
		}
        else 
        {
            $html    = "$whitespace<!-- $tag --><a$class href=\"$url\" onclick=\"window.open(this.href);return false;\">$text</a><!-- $tag -->$append";
        }
and there is a Link in new window bbcode somewhere in the db here.
Board rules! No PM support
Locked