View Full Version : Link not open new window in certain forum
I'm looking for a way to make it so links posted in a certain forum don't open a new window, but instead open in the same window. Maybe somehow setup a new template to display the link - that way one can preserve the header and not just open the link by itself.
Would this work? I'm specifically referring to links such as images (similiar to the "attachment editor", but not using attachments and only working in a specified forum(s)). But I suppose this could work with other websites as well - you know when you click a link from an email in hotmail it will display a hotmail header and the page below? That's kinda what I'm looking for.
Anyone interested in helping out, making, or pointing me in the right direction? It'd be awfully handy.
Logician
04-05-2003, 08:58 PM
edit functions.php, find:
function checkurl($url, $hyperlink="") {
global $bburl;
Replace it as:
function checkurl($url, $hyperlink="") {
global $bburl,$thread;
a few lines below find:
return "<a href=\"$bburl/gourl.php?url=".urlencode($righturl)."\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
Replace it as:
if ($thread['forumid']==X) {return "<a href=\"$bburl/gourl.php?url=".urlencode($righturl)."\">".str_replace('\"', '"', $hyperlink)."</a>";}
else {return "<a href=\"$bburl/gourl.php?url=".urlencode($righturl)."\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";}
(Replace X with forumid)
Find:
function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmi lies,$dobbcode)
{ // parses text for vB code, smilies and censoring
global $DB_site,$wordwrap,$allowdynimg, $bbuserinfo;
Replace it as:
function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmi lies,$dobbcode)
{ // parses text for vB code, smilies and censoring
global $DB_site,$wordwrap,$allowdynimg, $bbuserinfo, $thread;
find:
$replacearray = array(
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"<a href=\"http://www.\\6\" target=\"_blank\">\\8</a>",
"<a href=\"\\5\" target=\"_blank\">\\7</a>",
"<a href=\"http://www.\\5\" target=\"_blank\">\\5</a>",
"<a href=\"\\4\" target=\"_blank\">\\4</a>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"java script:",
"about :",
"vbscript :"
);
Replace it as:
if ($thread['forumid']==X) {
$replacearray = array(
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"<a href=\"http://www.\\6\">\\8</a>",
"<a href=\"\\5\">\\7</a>",
"<a href=\"http://www.\\5\">\\5</a>",
"<a href=\"\\4\">\\4</a>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"java script:",
"about :",
"vbscript :"
);
}
else
{
$replacearray = array(
"<ol type=\"\\5\">\\7</ol>",
"<ul>\\4</ul>",
"<li>",
"<a href=\"http://www.\\6\" target=\"_blank\">\\8</a>",
"<a href=\"\\5\" target=\"_blank\">\\7</a>",
"<a href=\"http://www.\\5\" target=\"_blank\">\\5</a>",
"<a href=\"\\4\" target=\"_blank\">\\4</a>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"</normalfont><blockquote><pre><smallfont>code:</smallfont><hr>\\5<hr></pre></blockquote><normalfont>",
"java script:",
"about :",
"vbscript :"
);
}
(Replace X with your forumid)
Enjoy..
Wow! Thanks, Logician. I'm unable to find the very first set of instructions, though, in my functions.php. I have the line:
function checkurl($url, $hyperlink="") {
but not the second one below it. Here's what I have, lines 910-922 of functions.php v2.2.8.
// ###################### Start checkurl #######################
function checkurl($url, $hyperlink="") {
$righturl = $url;
if(!preg_match("![a-z]://!si", $url)) {
$righturl = "http://$righturl";
}
// remove threat of users including javascript in url
/*$righturl = preg_replace("/javascript:/si", "java script:", $righturl);
$righturl = preg_replace("/about:/si", "about :", $righturl);*/
$hyperlink = iif(trim($hyperlink)=="" or $hyperlink==$url, iif(strlen($url)>55,substr($url,0,35)."...".substr($url,-15),$url) ,$hyperlink);
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
}
Logician
04-06-2003, 05:14 PM
[edit] correction for your vb version:
STEP 2:
find
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
replace it as:
if ($thread['forumid']==X) {return "<a href=\"$righturl\" >".str_replace('\"', '"', $hyperlink)."</a>";
}
else {return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
}
:( If I just apply the changes you mention in Post #4, I get the following parse error.
Parse error: parse error, unexpected ',' in /home/xxxx/public_html/forums/admin/functions.php on line 920
Fatal error: Call to undefined function: vbdate() in /home/xxxx/public_html/forums/admin/sessions.php on line 399
If I apply the changes in Post #4, combined with the third step in post #2, here's the parse error I get.
Parse error: parse error, unexpected ',' in /home/xxx/public_html/forums/admin/functions.php on line 939
Fatal error: Call to undefined function: vbdate() in /home/xxx/public_html/forums/admin/sessions.php on line 399
Line 939 of Functions.php is the newly inserted if ($thread['forumid']==27) {return "<a href=\"$righturl\" >".'\"', '"', $hyperlink)."</a>";
I did notice that didn't match my original line (minus the "target=_blank" of course) because the original line has "str_replace" in it. Would this matter? I tried editing around a bit to see if I could get any of it to work, but just a slew of parse errors.
Logician
04-06-2003, 08:07 PM
the code in post 2 is tested in 2.2.6 and working ok.
If you have a different line all you have to do is to apply the hack like this:
if ($thread['forumid']==27)
{
line without target=\"_blank\"
}
else
{
original line goes here.
}
so if your line is
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
it should be changed as:
if ($thread['forumid']==27)
{
return "<a href=\"$righturl\">".str_replace('\"', '"', $hyperlink)."</a>";
}
else
{
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"', '"', $hyperlink)."</a>";
}
(also dont forget to add part: )
global $bburl,$thread;
:D All the errors are cleared up and the code is in without problem. Thank you, Logician. But it still doesn't open links inside forumid==27 in the same page. I'm thinking I might need to go with the hack that allows links on the same server to open in a page, other links open in new window.
Logician
04-09-2003, 06:37 AM
if hack works for you, yep go ahead..
If it does not do the trick, come back here and we can figure out what's wrong. :) I know my code works because I tested it before posting here..
:D All the errors are cleared up and the code is in without problem. Thank you, Logician. But it still doesn't open links inside forumid==27 in the same page. I'm thinking I might need to go with the hack that allows links on the same server to open in a page, other links open in new window.
Rose, if it doesn't open the links inside of the forum page as you desired, does this hack at least open the links inside the same (original) window where you clicked the link?
Logician, could you let me know which version of vB that your original instructs were for? (I'm looking for a simple hack that opens any and all clicked links on my board onto the same window from where the link was clicked at (in other words I don't want links to open in a new window). Thanks. :nervous:
Logician
03-21-2004, 09:18 AM
It has been over a year :) but I guess I gave it for 2.2.6 and I believe it should work in all 2.x
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.