vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   BB Code Enhancements - Open local links in same window; external links in new window (https://vborg.vbsupport.ru/showthread.php?t=286030)

djbaxter 07-27-2012 10:00 PM

Open local links in same window; external links in new window
 
1 Attachment(s)
By default, vBulletin opens all links in posts in a new window (target="_blank").

This mod opens local links (i.e., links from your domain) in the same window (target="_self"), and external links in a new window or tab (target="_blank").

INSTRUCTIONS:

AdminCP >> Style Manager >> Common Templates >> headinclude

FIND in headinclude (this is where I added the code but probably anywhere would work):

PHP Code:

<vb:if condition="$stylevar['favicon']">
    <
link rel="Shortcut Icon" href="{vb:stylevar favicon}" type="image/x-icon" />
</
vb:if> 

ADD AFTER:

PHP Code:

<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<
script type="text/javascript">
$(
document).ready(function() {
    $(
"a[href^=http]").each(function(){
        if(
this.href.indexOf(location.hostname) == -1) {
           $(
this).attr('target','_blank');
        }else{
           $(
this).attr('target','_self');
        }
    })
});
</
script

Save. Done. :)

Thanks to my son, Wilder Tweedale, for assistance with the code.

Update:

Quote:

Originally Posted by BirdOPrey5 (Post 2352230)
VB4 uses jquery on only a few pages. Yahoo YUI is the default library on all pages.

BOP5 has just published a javascript version of this as a product, which may be easier for many to implement and which avoids possible increases in page load times.

See http://www.qapla.com/mods/misc.php?d...extlinkingbop5

djbaxter 07-28-2012 12:22 PM

Before someone asks the obvious question...

Q: How is this mod different from the mod by SweCastel https://vborg.vbsupport.ru/showthread.php?t=256195?

A: SweCastel's mod requires editing one of the core vBulletin files. I dislike doing that because it means re-editing the file with every update. The current mod requires template edits only.

BirdOPrey5 07-28-2012 08:23 PM

This is a great idea, I use a custom BBCode for local links on my forum but it's annoying to have to worry about which are local and which aren't.

I would just give a heads up to people if they are already loading jquery on their pages they don't need to load it twice- actually 2 different jquery versions may conflict.

djbaxter 07-28-2012 10:58 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2352195)
This is a great idea, I use a custom BBCode for local links on my forum but it's annoying to have to worry about which are local and which aren't.

Thanks. :)

Quote:

Originally Posted by BirdOPrey5 (Post 2352195)
I would just give a heads up to people if they are already loading jquery on their pages they don't need to load it twice- actually 2 different jquery versions may conflict.

To be honest, I thought it was loaded in native vBulletin installations but couldn't get the script to work without the load line added.

BirdOPrey5 07-28-2012 11:51 PM

VB4 uses jquery on only a few pages. Yahoo YUI is the default library on all pages.

djbaxter 08-04-2012 12:07 PM

Quote:

Originally Posted by BirdOPrey5 (Post 2352230)
VB4 uses jquery on only a few pages. Yahoo YUI is the default library on all pages.

BOP5 has just published a javascript version of this as a product, which may be easier for many to implement and which avoids possible increases in page load times.

See http://www.qapla.com/mods/misc.php?d...extlinkingbop5

BirdOPrey5 08-04-2012 08:21 PM

I didn't want to release my own here since if it wasn't for yours I wouldn't have thought to do it. ;)

djbaxter 08-04-2012 08:48 PM

Well, suffice it to say that I'm now using yours. :)

And I wouldn't be offended in the slightest if you re-released your mod here.

BirdOPrey5 08-05-2012 01:29 PM

Thanks. I put it up here: https://vborg.vbsupport.ru/showthread.php?t=286348 :up:

djbaxter 08-05-2012 01:39 PM

Excellent... To others, I'm now using the BOP5 mod on four vB4 forums... highly recommended.


All times are GMT. The time now is 12:05 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01566 seconds
  • Memory Usage 1,745KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete