Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-05-2003, 02:40 PM
Rose's Avatar
Rose Rose is offline
 
Join Date: Nov 2001
Location: K-Town, Germany
Posts: 619
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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.
Reply With Quote
  #2  
Old 04-05-2003, 08:58 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

edit functions.php, find:

PHP Code:
function checkurl($url$hyperlink="") {
global 
$bburl
Replace it as:
PHP Code:
function checkurl($url$hyperlink="") {
global 
$bburl,$thread
a few lines below find:
PHP Code:
return "<a href=\"$bburl/gourl.php?url=".urlencode($righturl)."\" target=\"_blank\">".str_replace('\"''"'$hyperlink)."</a>"
Replace it as:
PHP Code:
 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:
PHP Code:
function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode)
// parses text for vB code, smilies and censoring

  
global $DB_site,$wordwrap,$allowdynimg$bbuserinfo
Replace it as:
PHP Code:
function bbcodeparse2($bbcode,$dohtml,$dobbimagecode,$dosmilies,$dobbcode)
// parses text for vB code, smilies and censoring

  
global $DB_site,$wordwrap,$allowdynimg$bbuserinfo$thread
find:
PHP Code:
        $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:

PHP Code:
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..
Reply With Quote
  #3  
Old 04-06-2003, 04:01 PM
Rose's Avatar
Rose Rose is offline
 
Join Date: Nov 2001
Location: K-Town, Germany
Posts: 619
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow! Thanks, Logician. I'm unable to find the very first set of instructions, though, in my functions.php. I have the line:

PHP Code:
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.

PHP Code:
// ###################### 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==$urliif(strlen($url)>55,substr($url,0,35)."...".substr($url,-15),$url) ,$hyperlink);
  return 
"<a href=\"$righturl\" target=\"_blank\">".str_replace('\"''"'$hyperlink)."</a>";

Reply With Quote
  #4  
Old 04-06-2003, 05:14 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[edit] correction for your vb version:

STEP 2:
find
PHP Code:
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"''"'$hyperlink)."</a>"
replace it as:
PHP Code:
if ($thread['forumid']==X) {return "<a href=\"$righturl\" >".str_replace('\"''"'$hyperlink)."</a>";
}
else {return 
"<a href=\"$righturl\" target=\"_blank\">".str_replace('\"''"'$hyperlink)."</a>";

Reply With Quote
  #5  
Old 04-06-2003, 05:41 PM
Rose's Avatar
Rose Rose is offline
 
Join Date: Nov 2001
Location: K-Town, Germany
Posts: 619
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If I just apply the changes you mention in Post #4, I get the following parse error.

[parse]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[/parse]

If I apply the changes in Post #4, combined with the third step in post #2, here's the parse error I get.

[parse]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[/parse]

Line 939 of Functions.php is the newly inserted
PHP Code:
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.
Reply With Quote
  #6  
Old 04-06-2003, 08:07 PM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:

PHP Code:
if ($thread['forumid']==27
{
line without target=\"_blank\"
}
else
{
original line goes here.

so if your line is

PHP Code:
return "<a href=\"$righturl\" target=\"_blank\">".str_replace('\"''"'$hyperlink)."</a>"
it should be changed as:

PHP Code:
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: )
PHP Code:
global $bburl,$thread
Reply With Quote
  #7  
Old 04-08-2003, 08:13 PM
Rose's Avatar
Rose Rose is offline
 
Join Date: Nov 2001
Location: K-Town, Germany
Posts: 619
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 04-09-2003, 06:37 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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..
Reply With Quote
  #9  
Old 03-19-2004, 03:44 PM
Xube's Avatar
Xube Xube is offline
 
Join Date: Nov 2001
Location: private
Posts: 67
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Rose
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:
Reply With Quote
  #10  
Old 03-21-2004, 09:18 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 10:07 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04322 seconds
  • Memory Usage 2,317KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (17)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete