PDA

View Full Version : Internal links


DemOnstar
12-14-2015, 02:49 PM
How do I get links to open in the same tab instead of another one?
I think I remember having the same problem with 4 but it has been so long that I have forgotten.

Thanks. . .

MarkFL
12-14-2015, 03:25 PM
Try changing the target attribute to target="_self" to the anchor (<a></a>) tag(s). :) Since this is the default, you could simply remove the target="_blank" from the anchor, and this should work too.

Dragonsys
12-14-2015, 05:20 PM
How do I get links to open in the same tab instead of another one?
I think I remember having the same problem with 4 but it has been so long that I have forgotten.

Thanks. . .

earlier versions of vb4 had this issue, but it was later corrected. I used to have a plugin which fixed it, but not sure if I still have the code lying around.

Try changing the target attribute to target="_self" to the anchor (<a></a>) tag(s). :) Since this is the default, you could simply remove the target="_blank" from the anchor, and this should work too.

wouldn't that change all links, not just internal ones?

MarkFL
12-14-2015, 05:33 PM
...wouldn't that change all links, not just internal ones?

I wasn't sure, but I thought perhaps there was a specific link (or links) in certain templates that the OP wanted to change.

Otherwise, changing all internal links could likely be done using javascript, as expressed by Joe in his product:

Open Internal Links in Same Tab - Ported by BOP5 (VB 4.x & VB 3.x) (https://vborg.vbsupport.ru/showthread.php?t=286348)

Dragonsys
12-14-2015, 06:00 PM
Open Internal Links in Same Tab - Ported by BOP5 (VB 4.x & VB 3.x) (https://vborg.vbsupport.ru/showthread.php?t=286348)

Cool, I figured there was a plugin out there for it :)

DemOnstar
12-14-2015, 08:12 PM
I used the the product mentioned but I thought it was for 4?
I notice that all links open up a new tab in 5 and perhaps 4 was the same? Sometimes it is useful and other times not, so I guess each individual link has to be changed rather than a global solution.

Okay. . . .Thanks for the pointers. . .

Dragonsys
12-14-2015, 08:22 PM
I used the the product mentioned but I thought it was for 4?
I notice that all links open up a new tab in 5 and perhaps 4 was the same? Sometimes it is useful and other times not, so I guess each individual link has to be changed rather than a global solution.

Okay. . . .Thanks for the pointers. . .

The product linked is for 4, Mark was just giving it as an example.
I do not have a license for 5, so I really can't help much more, as I cannot look at the code, but I'm pretty sure a plugin will be required.

DemOnstar
12-14-2015, 08:31 PM
I checked it and noticed this. . .

Should be compatible with all vBulletins between 3.6.0 and 5.0.0. (So all 3.8.x and 4.x.x for sure.)

I think I may try it in 5 and see what happens . . .

Cheers. . .

Dragonsys
12-14-2015, 08:51 PM
I checked it and noticed this. . .



I think I may try it in 5 and see what happens . . .

Cheers. . .

oh cool. let us know how it goes

DemOnstar
12-15-2015, 10:43 AM
oh cool. let us know how it goes

It went like this. . .


The following dependencies were not met:

This product is not compatible with version 5.1.10 of vBulletin. (Compatible starting with 3.6.0 / Incompatible with 5.0.0 and greater)

Worth a try. . .

And for your curiosity, this is what the .xml looks like.

<?xml version="1.0" encoding="ISO-8859-1"?>

<product productid="intextlinkingbop5" active="1">
<title>Open Internal Links In Same Page - Ported By BOP5</title>
<description>This will add JavaScript to every page that will make all links to the same domain open in the same tab or window. Only external links will open in new tabs.</description>
<version>1.0</version>
<url><![CDATA[http://www.qapla.com/mods/misc.php?do=producthelp&pid=intextlinkingbop5]]></url>
<versioncheckurl><![CDATA[http://www.qapla.com/mods/misc.php?do=productcheck&pid=intextlinkingbop5]]></versioncheckurl>
<dependencies>
<dependency dependencytype="vbulletin" minversion="3.6.0" maxversion="5.0.0" />
</dependencies>
<codes>
</codes>
<templates>
</templates>
<stylevardfns>
</stylevardfns>
<stylevars>
</stylevars>
<plugins>
<plugin active="1" executionorder="5">
<title>Add Internal Linking JavaScript</title>
<hookname>replacement_vars</hookname>
<phpcode><![CDATA[// Blankwin JavaScript function
// written by Alen Grakalic, provided by Css Globe (cssglobe.com)
// please visit http://cssglobe.com/post/1281/open-external-links-in-new-window-automatically/ for more info
// MODIFIED BY BirdOPrey5 (vbulletin.org / Qapla.com) for use on vBulletin forums

global $vbulletin;

$ddom = $_SERVER['HTTP_HOST'];

if ($vbulletin->options['bop5bil_en'])
{
$domainslist = explode("\r\n" , $vbulletin->options['bop5bil_domains']);
if ($domainslist[0] == '')
$domainslist[0] = str_ireplace('www.', '', $ddom);

$di = 0;
$js_vars = 'var dlists = new Array(); ' . " \r\n";

$dmax = count($domainslist);

//At least 1 domain in list
while ($di < $dmax)
{
$js_vars .= " dlists[{$di}] = '" . $domainslist[$di] . "'; \r\n";
$di++;
}

$find = "</body>";

$replace = '
<script type="text/javascript">
this.blankwin = function(){
'. $js_vars . '
var hostname = window.location.hostname;
hostname = hostname.replace("www.","").toLowerCase();
var a = document.getElementsByTagName("a");
this.check = function(obj){
var href = obj.href.toLowerCase();
var dbopcount = 0;
if (href.indexOf("http://")!=-1)
{
for (jdi = 0; jdi <= dlists.length; jdi++)
{
if (href.indexOf(dlists[jdi]) == -1)
{
//alert("NO MATCH " + dlists[jdi] + " " + href);
dbopcount = dbopcount; //Do nothing
}
else
{
//alert("match " + dlists[jdi] + " " + href);
dbopcount++;
}
}
if (dbopcount > 0)
return true; //If this link URL was an internal URL
else //there were no matches to any internal domain, so leave it external
return false;
}
else
{
return false;
}
//return (href.indexOf("http://")!=-1 && href.indexOf(hostname)==-1) ? false : true;
};
this.set = function(obj){
obj.target = "_self";
};
for (var i=0;i<a.length;i++){
if(check(a[i])) set(a[i]);
};
};

// script initiates on page load.

this.addEvent = function(obj,type,fn){
if(obj.attachEvent){
obj[\'e\'+type+fn] = fn;
obj[type+fn] = function(){obj[\'e\'+type+fn](window.event );}
obj.attachEvent(\'on\'+type, obj[type+fn]);
} else {
obj.addEventListener(type,fn,false);
};
};
addEvent(window,"load",blankwin);
</script>
';

$newtext = str_replace ($find, $replace . $find, $newtext);
}]]></phpcode>
</plugin>
</plugins>
<phrases>
<phrasetype name="vBulletin Settings" fieldname="vbsettings">
<phrase name="setting_bop5bil_domains_desc" date="1343585395" username="BirdOPrey5" version="1.0"><![CDATA[List of domains that should be considered internal (they will open in the current window or tab), <b>one per line.</b> Do not include the "www." if any, just the domain name and extension.<br />
<br />
Example: <br />
<br />
qapla.com <br />
birdoprey5.com <br />
<br />
If left blank the mod will attempt to auto-detect the domain name.]]></phrase>
<phrase name="setting_bop5bil_domains_title" date="1343585395" username="BirdOPrey5" version="1.0"><![CDATA[List of Domains to Open in Same Tab/Window]]></phrase>
<phrase name="setting_bop5bil_en_desc" date="1343585395" username="BirdOPrey5" version="1.0"><![CDATA[Enables or disables the entire mod.]]></phrase>
<phrase name="setting_bop5bil_en_title" date="1343585395" username="BirdOPrey5" version="1.0"><![CDATA[Enable Mod?]]></phrase>
<phrase name="settinggroup_betterintlinksbop5" date="1343585395" username="BirdOPrey5" version="1.0"><![CDATA[Open Internal Links In Same Page - Ported By BOP5]]></phrase>
</phrasetype>
</phrases>
<options>
<settinggroup name="betterintlinksbop5" displayorder="65535">
<setting varname="bop5bil_en" displayorder="10">
<datatype>free</datatype>
<optioncode>yesno</optioncode>
<defaultvalue>1</defaultvalue>
</setting>
<setting varname="bop5bil_domains" displayorder="20">
<datatype>free</datatype>
<optioncode>textarea</optioncode>
</setting>
</settinggroup>
</options>
<helptopics>
</helptopics>
<cronentries>
</cronentries>
<faqentries>
</faqentries>
<navigation>
</navigation>
</product>


Cheers.