View Full Version : external links target=_blank, internal links target=_top?
boatdesign
01-03-2002, 03:00 AM
The default behavior in vBulletin is that when someone posts a URL vBulletin converts it to a clickable link and adds target=_blank. This is great for when people post links to other websites, etc. so that my forum stays open in the background.
But when people post internal links to other threads, it can get annoying for them to open in a new window.
Is there any way I could create an "if else" logic that would:
-add target="_blank" when creating autolinks to any external url
-except add target="_top" when creating autolinks to mydomain.com/forum threads?
(I guess the if else logic would actually work the other way around, if the URL=myurl, vBulletin would add target="_top", else it would add "target="_blank".
How would I do this exactly?
Admin
01-03-2002, 10:06 AM
I'll see what I can do, shouldn't be too hard.
btw, you need to go to this (http://www.vbulletin.com/members/vbulletin.org.php) page and enter your username, to show you are licensed. (you will need to use your customer number and password to access that page)
This will give you access to post in this forum. :)
Admin
01-03-2002, 10:33 AM
Ok, try this.
In functions.php replace this:
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
with this:
return "<a href=\"$righturl\" target=\"".iif(strstr($righturl,"vbulletin.org"),"_top","_blank")."\">".str_replace('\"', '"', $hyperlink)."</a>";
change vbulletin.org to your own site domain (without www).
FireFly
I knew this might sound strang but I need this finction, so please help if you can
How can I chnge the target domain, for example to replace any vbulletin.org to vbulletin.com in the link
It will be even better if I could use $bburl so when I change it in the controle panel all the old links get updated :D
Please if this does not make sence, just ignore it :D
boatdesign
01-04-2002, 12:35 AM
Thanks FireFly,
But I replaced the text exactly as you have it above (changing only vbulletin.org to boatdesign.net) and it didn't work - still all links open in a new window. (I applied the change, it didn't work, I reverted to the old version, tried making the change again to be sure, all links still were to a new window, so I reverted to the old functions.php for now.)
ayasystems
10-27-2008, 01:01 PM
In 3.7 version
class_bbcode.php
replace
return "<a href=\"$rightlink\" target=\"_blank\">$text</a>";
WITH
return "<a href=\"$rightlink\" target=\"".iif(strstr($rightlink,"YOURDOMAIN.COM"),"_top","_blank")."\">$text</a>";
THANKS!
jeremyalyea
01-10-2009, 05:50 PM
This thread could help a lot of people. I searched high and low for it and finally found it. Thank you ayasyystems!
I tried this and it works for external links, but sometimes replaces the text linked to with "internal linking thread" and then just links back to the same thread it's written in. Instead of going to the URL it should.
I reverted back to the vB default and the links work correctly again.
This was on vB 3.8 BTW.
Omega.Rav
04-01-2009, 12:35 AM
for vBulletin 3.8.x users: I replaced target "_top" with "_self" and seems to work fine so far :)
return "<a href=\"$rightlink\" target=\"".iif(strstr($rightlink,"YOURDOMAIN.COM"),"_self","_blank")."\">$text</a>";
dacho
09-18-2009, 07:57 AM
It's work fine.... but it's not working in the signature links :(
do you have any idea ????
dacho
02-20-2010, 07:38 PM
How I use it in VB4 ?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.