View Full Version : Mini Mods - Same Window For Local Links
Viper007Bond
11-06-2006, 10:00 PM
Another really simple plugin from me.
I wanted local links (i.e. ones to other parts of the forum) to not open in a new tab. So, I wrote a little modifier to make that happen and decided to share the code.
Tested on my forum, but let me know if you encounter any issues. :)
How it works:
It hooks in at the end of the BBCode parser, after the parser has transformed the BBCode into HTML. My plugin then removes the target="_blank" off of links that start with your forum base URL.
Upgrading from version 1.0.1 or 1.0.0:
Delete the plugin and then install the new product.
It doesn't seem to be working on old posts!
The output of the BBCode parser and such is cached by vB. Just rebuilt your post cache (it's under "Update Counters") and all will be good.
==============================
DON'T FORGET TO CLICK INSTALL!
https://vborg.vbsupport.ru/ (https://vborg.vbsupport.ru/vborg_miscactions.php?do=installhack&threadid=130966)
==============================
Viper007Bond
11-07-2006, 06:22 AM
CHANGELOG:
v1.0.3: if your base URL contains "www.", it's now optional and this plugin will affect both www.yoursite.com as well as yoursite.com
v1.0.2: cached versions of posts were still having their links open in new windows, this is now hopefully fixed
v1.0.1: attachment.php links now continue to open in a new window
v1.0.0: initial release
Snake
11-07-2006, 09:14 AM
Thanks buddy! :)
Cheertobi
11-07-2006, 02:20 PM
/me clicks install!
Thanks!
4yBak
11-07-2006, 05:01 PM
how this plugin know which links are local? Or this plugin use own bb-code? Also, can you do option like: not display local links for specific usergropus (for example: unregistering users) ?
TCattitude
11-07-2006, 05:39 PM
how this plugin know which links are local? Or this plugin use own bb-code? Also, can you do option like: not display local links for specific usergropus (for example: unregistering users) ?
If the linked url have your vbulletin['bburl'] in that url, so the plugin re-write the "a href" code to change the "target" of the link, and left the link intact.
Nice and simple plugin ;)
This really need to be a standard vbulletin option (local links not use "_blank" target; local links open in the same window)
w1z4rd
11-07-2006, 05:56 PM
Finally, ... this works great just remember it does'nt take effect on posts before the installation unless you edit them. Sweet little plugin, thanks.
Viper007Bond
11-07-2006, 06:33 PM
Finally, ... this works great just remember it does'nt take effect on posts before the installation unless you edit them. Sweet little plugin, thanks.
No, it does, just flush your post cache. ;)
This modifies the output of the BBCode parser (after the BBCode is applied) but that output gets cached by vB.
PsicoByte
11-07-2006, 10:32 PM
<font color="Lime">*install*</font>
Thanks!! :laugh:
abramelin
11-08-2006, 12:09 AM
good but its going to open the attachment images in the same window too so this is not good :/
Viper007Bond
11-08-2006, 12:13 AM
good but its going to open the attachment images in the same window too so this is not good :/
It shouldn't touch the items in the attachment box as I don't believe those are run though the BBCode parser (why would they be?).
However, yeah, [ATT ACH]12345[/ATTACH] would be probably be affected. I'll exclude attachment.php links.
abramelin
11-08-2006, 12:17 AM
if you can exclude them then im going to install this lovely simple mod,thanks.
Viper007Bond
11-08-2006, 01:57 AM
Gah, man I suck at regex. :(
Viper007Bond
11-08-2006, 09:13 AM
Alright, attachment.php is now excluded and will continue to open in a new tab/window. :)
Nathan2006
11-10-2006, 02:15 PM
Thank you Viper007Bond,
I requested (https://vborg.vbsupport.ru/showthread.php?t=113548) something like this a long time ago because I hated new windows opening all the time on local links.
I always had to use the html code <a href=""><span style="color: blue;"> Here </span></a> to open links in the same window :(
But this great hack has now made me very happy:D
And also should be default on all VB boards.
Thanks again
Install:)
funkmeister
11-12-2006, 04:56 AM
Just rebuilt your post cache (it's under "Update Counters") and all will be good.Dumb question - which option in "Update Counters" needs to be used? Only one closest to what you describe is "Update Post Counts" - is that the one or a different one?
Anyway, works great (on my new posts) - thanks.
Viper007Bond
11-12-2006, 07:50 AM
Dumb question - which option in "Update Counters" needs to be used? Only one closest to what you describe is "Update Post Counts" - is that the one or a different one?
Anyway, works great (on my new posts) - thanks.
No, the "Rebuild Post Cache" one. 6th one down. ;)
funkmeister
11-12-2006, 02:07 PM
No, the "Rebuild Post Cache" one. 6th one down. ;)Ummm, I don't have that one as an option - the 6th one down on my list is "Empty Signature Cache" - I'm on 3.6.2 - is this a new option only in 3.6.3 or is it reliant on someother setting in order for it to be made available as an option?
Also, can you add a feature to take into a count those "showthread" posts that include the syntax "showthread.php?p=22946#post22946" - these "normally" open in a new window and include a "Close Window" button on the bottom of the displayed page. Of course, when a user clicks it and with this add-on installed, it will prompt them to close it and in turn close down the whole browser, since it actually now opens in the same page. So can you make it so that these type of URL's continue to open in a new window.
Thanks.
Viper007Bond
11-12-2006, 09:41 PM
Ummm, I don't have that one as an option - the 6th one down on my list is "Empty Signature Cache" - I'm on 3.6.2 - is this a new option only in 3.6.3 or is it reliant on someother setting in order for it to be made available as an option?
No, I had the option in 3.6.2. Odd. *shrugs*
Also, can you add a feature to take into a count those "showthread" posts that include the syntax "showthread.php?p=22946#post22946" - these "normally" open in a new window and include a "Close Window" button on the bottom of the displayed page. Of course, when a user clicks it and with this add-on installed, it will prompt them to close it and in turn close down the whole browser, since it actually now opens in the same page. So can you make it so that these type of URL's continue to open in a new window.
Thanks.
showpost.php you mean? And good point. Thanks.
funkmeister
11-12-2006, 11:28 PM
No, I had the option in 3.6.2. Odd. *shrugs*
showpost.php you mean? And good point. Thanks.
Yeah, I'm doing the same thing *shrug* and scratching my head :confused:
Yes, "showpost.php" is what I meant to say!
Viper007Bond
11-12-2006, 11:29 PM
Yes, "showpost.php" is what I meant to say!
I just remembered -- upgrade to 3.6.3. That page doesn't show the "Close Window" button anymore unless it really is a pop-up. ;)
funkmeister
11-13-2006, 03:45 AM
I just remembered -- upgrade to 3.6.3. That page doesn't show the "Close Window" button anymore unless it really is a pop-up. ;)
OK, thanks. If I see an issue after I upgrade I'll get back to you, but it sounds like it's sorted :)
Thanks.
Viper007Bond
11-25-2006, 04:32 AM
Small update. Cached versions of posts were still having their links open in new windows, this is now hopefully fixed.
Nathan2006
11-25-2006, 05:17 AM
Small update. Cached versions of posts were still having their links open in new windows, this is now hopefully fixed.
Thank you for the update Viper007Bond
All is working well :D
Viper007Bond
11-25-2006, 05:37 AM
Oh, I also moved it from a plugin to a product to make things easier. Best to remove the old plugin (it won't hurt, but it'll just execute more code otherwise).
XFSImperial
11-26-2006, 01:28 AM
I've installed this mo; do you think there's anyway to make it work http://mydomain.com the same way it currently works for http://www.mydomain.com?
R1lover
11-26-2006, 03:15 AM
Im not sure what this does that you can't do with BBcode?
Viper007Bond
11-27-2006, 08:39 PM
I've installed this mo; do you think there's anyway to make it work http://mydomain.com the same way it currently works for http://www.mydomain.com?
Yeah, there is. I'll get to work on it. :)
Viper007Bond
11-27-2006, 08:41 PM
Im not sure what this does that you can't do with BBcode?
Do this on your forum:
http://yoursite.com/forum/showthread.php?t=123
If you click that link, it opens in a new window. This makes it open in the same window.
You cannot do that with vB fresh outta the box as far as I'm aware.
Viper007Bond
11-30-2006, 12:40 AM
I've installed this mo; do you think there's anyway to make it work http://mydomain.com the same way it currently works for http://www.mydomain.com?
Updated. Should work fine now for this. :)
da420
11-30-2006, 06:16 AM
I like the idea of this hack. Doesn't work for me on 3.6.4 unfortunately.
Viper007Bond
11-30-2006, 10:21 AM
I like the idea of this hack. Doesn't work for me on 3.6.4 unfortunately.
Really? Works fine for me here in 3.6.4: http://forums.finalgear.com/showthread.php?t=15146
Did you read the part about how it doesn't affect posts posted before you installed the product unless you rebuild the post cache?
da420
11-30-2006, 07:34 PM
Really? Works fine for me here in 3.6.4: http://forums.finalgear.com/showthread.php?t=15146
Did you read the part about how it doesn't affect posts posted before you installed the product unless you rebuild the post cache?
Yep, searched this entire thread.
I rebuilt the post cache, and it does not work on new or old posts. It's too bad, cuz this would be great to have working on the forum. :)
Viper007Bond
12-01-2006, 03:37 AM
Yep, searched this entire thread.
I rebuilt the post cache, and it does not work on new or old posts. It's too bad, cuz this would be great to have working on the forum. :)
Temporarily disable any other products/plugins that are installed and see if that fixes it.
da420
12-01-2006, 03:41 PM
Temporarily disable any other products/plugins that are installed and see if that fixes it.
Disabled everything, and it still is opening all local links in a new window. Even tried it in an unaltered, unedited, default vBulletin template.
Viper007Bond
12-02-2006, 02:40 AM
Disabled everything, and it still is opening all local links in a new window. Even tried it in an unaltered, unedited, default vBulletin template.
Check your vB URL in your options page. This plugin uses it to determine if a link is local or not. For testing, make sure to use a URL that starts with EXACTLY that string.
da420
12-02-2006, 03:35 AM
Check your vB URL in your options page. This plugin uses it to determine if a link is local or not. For testing, make sure to use a URL that starts with EXACTLY that string.
Tried exactly my site's url, copy and paste from ACP.
Still not opening up in same window.
Thanks for the help. :)
Viper007Bond
12-02-2006, 07:35 AM
Tried exactly my site's url, copy and paste from ACP.
Still not opening up in same window.
Thanks for the help. :)
In your ACP, do you have "www." or no?
Try this simpler version of my product and see if it works or not.
da420
12-02-2006, 07:20 PM
In your ACP, do you have "www." or no?
Try this simpler version of my product and see if it works or not.
I have www.
Still not working on my forum. Uninstalled the original product, and installed this lite one, and still not working.
Viper007Bond
12-03-2006, 12:13 AM
I'm outta ideas then. It should be working. :(
adonfun
12-27-2006, 11:24 PM
Thanks, great mod!! Installed it
I rebuilded the post cach but I get the message that a popup was prevented to open in FF...
Or do I have to wait for a while? :)
TheMilkCarton
07-29-2007, 01:57 PM
Hmm... it's been a long time since anyone has said anything, but I'll be hopeful that someone can answer this..
I looked in the plugin code and it SEEMS to exclude "attachment.php" so that attachments still open in a new window, but it's still stripping "target="_blank"" from attachment links.
I highlighted the attachment.php code in red:if ( FALSE !== strstr($vbulletin->options['bburl'], '://www.') ) {
$locallinks_search = '#\<a href="' . str_replace('://www.', '(://www.|://)', $vbulletin->options['bburl']) . '/((?!attachment.php).*?)" target="_blank"\>#i';
$locallinks_replace = '<a href="' . $vbulletin->options['bburl'] . '/$2">';
$text = preg_replace($locallinks_search, $locallinks_replace, $text);
$this->cached['text'] = preg_replace($locallinks_search, $locallinks_replace, $this->cached['text']);
} else {
$locallinks_search = '#\<a href="' . $vbulletin->options['bburl'] . '/((?!attachment.php).*?)" target="_blank"\>#i';
$locallinks_replace = '<a href="' . $vbulletin->options['bburl'] . '/$1">';
$text = preg_replace($locallinks_search, $locallinks_replace, $text);
$this->cached['text'] = preg_replace($locallinks_search, $locallinks_replace, $this->cached['text']);
}So is this code excluding or including attachment.php? I'm not exactly fluent in regex. :)
vuiveclub
02-20-2008, 11:43 AM
Hello
Can I use this mod for some forums only, I do not want to use for my all board. Thank you :)
inciarco
02-20-2008, 02:32 PM
Great Mod!! :up::up::up:
Works Fine with vB 3.6.7 PL1!! :up::up::up:
Thanks For Sharing It!! ;)
My Best Regards!! ;)
:)
Dingo14
03-04-2008, 12:09 AM
installed works great thanks
andreamarucci
03-05-2008, 03:39 PM
installed! My compliments, now I test this one...
plasticsurgery
04-27-2008, 08:20 PM
Just installed. Thanks so much!!!
justchil
05-03-2008, 01:25 AM
Check your vB URL in your options page. This plugin uses it to determine if a link is local or not. For testing, make sure to use a URL that starts with EXACTLY that string.
This helped me! I didn't have www. but am using it in my urls :) Cheers!
karrerax
05-11-2008, 04:17 PM
GREAT . I was im looking for !!!
Cliks install
andreamarucci
05-13-2008, 09:24 AM
I've upgraded to 3.7. Does this work on 3,7?
Dingo14
08-02-2008, 09:59 PM
same question will this work on 3.7
Milez
04-23-2009, 09:33 PM
Tested and working on vB 3.8.2. Thanks to the author :)
Bommando
07-23-2009, 02:18 PM
Thanks for this. It's been bugging me for a while.
Installed :)
plasticsurgery
06-11-2010, 02:40 AM
Is there a version of this available for vB 4.0?
MikesSite
11-02-2011, 03:59 PM
Works on 3.8 but conflicts with AME
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.