vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Add-ons (https://vborg.vbsupport.ru/forumdisplay.php?f=245)
-   -   Mini Mods - Open Local links in same window, External in new window (https://vborg.vbsupport.ru/showthread.php?t=256195)

SweCastel 12-29-2010 10:00 PM

Open Local links in same window, External in new window
 
1 Attachment(s)
I did search for a easy solution to simply open a local link in the same window, and external links in a new window.

Did not find it, so I did make this. My first PHP script.

In the file:
includes/class_bbcode.php

Search for: standard URL hyperlink

3.1.5 (maybe 3.1.6?) And before:
Replace:
Code:

return "<a href=\"$rightlink\" target=\"_top\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
3.1.7 ->
Replace:
Code:

return "<a href=\"$rightlink\" target=\"_blank\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
With:

Code:

       
        if( is_int(  strpos(  strtolower( $rightlink ), "InsertYourDomainHere") ) )

        {
                return "<a href=\"$rightlink\" target=\"_top\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
        } else {
                return "<a href=\"$rightlink\" target=\"_blank\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
        }

InsertYourDomainHere = Should be replaced with your domain eg: vbulletin (exclude the last part of your domain eg .com / .org)
It didn?t work for me anyway.
Maybe because of vbulletin cutting down long texts? I dont really now.

And then update the CMS Cache.
AdminCP - vBulletin CMS - Clean CMS-Cache

However this works perfect for me.

// Daniel

dacho 12-30-2010 06:13 PM

It didnĀ“t work for me

utahraves 12-30-2010 06:24 PM

I have several parked domains. I would like this if I could use multiple domains.
Ex: utahraves.com and utrave.org = same site, I would need to be able to put both domains in that for my site to work.

Dr.osamA 12-31-2010 04:28 PM

ander test

thank you bro

dormopoco 01-15-2011 07:20 AM

work whit attachments? i have on my site Bug Whit attacment. i need open in new windows

SweCastel 02-05-2011 11:34 AM

Some update is done. Maybe it works now.

nacaruncr 02-08-2011 07:15 AM

It doesn't work in 4.0.x...

SweCastel 02-08-2011 07:21 AM

Quote:

Originally Posted by nacaruncr (Post 2160099)
It doesn't work in 4.0.x...

Sorry if it does not.
I works just fine in 4.1.1 so I guess thats what you need.
If you don?t want to customize it.

// D

angeljs 05-14-2011 08:19 PM

Doesn't work for me, either :(

kmfrei 09-13-2011 07:22 AM

Works out perfect with version 4.1.5. Thanx for having resolved this issue!

SweCastel 11-06-2011 09:44 AM

Works In: 4.1.7 PL2

SweCastel 11-20-2011 11:21 PM

Works In: 4.1.8

spillage 12-18-2011 09:59 PM

Did not work on 4.1.8 for me.
Used code as provided... tried all permutations for "InsertYourDomainHere".
Any additional thoughts?

barakuda 12-25-2011 10:45 AM

work for 4.1.9 and 3.7.

SweCastel 02-29-2012 11:51 PM

Works in 4.11.1

SweCastel 05-23-2012 12:32 AM

Works in 4.2

Dragonsys 06-05-2012 04:31 PM

You can do this with 1 single line of code as well:
Code:

return "<a href=\"$rightlink\" target=\"" . iif(strstr($rightlink,"yourdomain.com"),"_self","_blank") . "\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
Quote:

Originally Posted by utahraves (Post 2141471)
I have several parked domains. I would like this if I could use multiple domains.
Ex: utahraves.com and utrave.org = same site, I would need to be able to put both domains in that for my site to work.

add an elseif for each domain
Code:

       
        if( is_int(  strpos(  strtolower( $rightlink ), "InsertYourDomainHere") ) ) {
                return "<a href=\"$rightlink\" target=\"_top\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
        } elseif( is_int(  strpos(  strtolower( $rightlink ), "DomainName2") ) ) {
                return "<a href=\"$rightlink\" target=\"_top\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
        } else {
                return "<a href=\"$rightlink\" target=\"_blank\"" . ($is_external ? ' rel="nofollow"' : '') . ">$text</a>";
        }


SweCastel 07-25-2013 07:02 PM

Works in 4.2.1

DemOnstar 07-26-2013 03:56 AM

Quote:

Originally Posted by SweCastel (Post 2435365)
Works in 4.2.1

Confirmed here too.

Heckwork 11-08-2013 02:01 PM

Great, thanks!

4.2.2 confirmed as well


All times are GMT. The time now is 02:22 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.01132 seconds
  • Memory Usage 1,752KB
  • 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
  • (5)bbcode_code_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (20)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