View Full Version : [Need Help]Auto clickable links with tab [CODE] ?
pmk_1992
11-05-2010, 01:01 AM
Hi ,
i want to make auto clickable links when user use tab
exp :
when we put any link in tab [code] it will show like this:
[CODE]http://www.vbulletin.org
but i want it will automatic change to :
http://www.vbulletin.org
anybody know please help me.
Thank you.
imcool2121
10-16-2011, 05:31 PM
anyone plz provide solution of this. i also want this.
nerbert
10-16-2011, 11:06 PM
I got this to work in [code] tags and [html] tags but am having trouble with tags.
In includes/class_bbcode.php go to about line 1970 and modify as follows:
[PHP]
else
{
$blockheight = $this->fetch_block_height($code);
$template = 'bbcode_code';
}
//########### CLICKABLE LINK HACK ###########
$code = convert_url_to_bbcode($code);
$n = preg_match_all('#\.*\[/url\]#U', $code, $matches);
foreach($matches[0] AS $match)
{
$string = str_replace('[url]', '', $match);
$string = str_replace('', '', $string);
$html_url = '<a href="' . $string . '" target="_blank">' . $string . '</a>';
$code = str_replace($match, $html_url, $code);
}
//########## /CLICKABLE LINK HACK ###########
$templater = vB_Template::create($template, true);
$templater->register('blockheight', $blockheight);
$templater->register('code', $code);
return $templater->render();
}
There's probably a smarter way to do this but I'm not very smart.
imcool2121
10-17-2011, 10:29 AM
I got this to work in [code] tags and [html] tags but am having trouble with tags.
In includes/class_bbcode.php go to about line 1970 and modify as follows:
[PHP]
else
{
$blockheight = $this->fetch_block_height($code);
$template = 'bbcode_code';
}
//########### CLICKABLE LINK HACK ###########
$code = convert_url_to_bbcode($code);
$n = preg_match_all('#\.*\[/url\]#U', $code, $matches);
foreach($matches[0] AS $match)
{
$string = str_replace('[url]', '', $match);
$string = str_replace('', '', $string);
$html_url = '<a href="' . $string . '" target="_blank">' . $string . '</a>';
$code = str_replace($match, $html_url, $code);
}
//########## /CLICKABLE LINK HACK ###########
$templater = vB_Template::create($template, true);
$templater->register('blockheight', $blockheight);
$templater->register('code', $code);
return $templater->render();
}
There's probably a smarter way to do this but I'm not very smart.
i tried your this code. and i see this error when i post links in code -
Fatal error: Call to undefined function convert_url_to_bbcode() in /public_html/myforum.com/includes/class_bbcode.php on line 1995
i am using vbulletin 4.1.7
plz help... i need all links in code tag clickable.
nerbert
10-17-2011, 12:33 PM
Oops, I didn't test this any further than Preview. Change the hack to :
//########### CLICKABLE LINK HACK ###########
require_once(DIR . '/includes/functions_newpost.php');
$code = convert_url_to_bbcode($code);
$n = preg_match_all('#\.*\[/url\]#U', $code, $matches);
foreach($matches[0] AS $match)
{
$string = str_replace('[url]', '', $match);
$string = str_replace('', '', $string);
$html_url = '<a href="' . $string . '" target="_blank">' . $string . '</a>';
$code = str_replace($match, $html_url, $code);
}
//########## /CLICKABLE LINK HACK ###########
imcool2121
10-17-2011, 12:59 PM
wow man, you are just amazing.
you made my day....thanks sooooo much. :)
only one more request...
this code make links in code clickable only if they are posted after today.
but it does not make those links in code clickable which have been already posted.
can you do something so that the links in code that are already posted before applying this hack also become clickable ??
Oops, I didn't test this any further than Preview. Change the hack to :
//########### CLICKABLE LINK HACK ###########
require_once(DIR . '/includes/functions_newpost.php');
$code = convert_url_to_bbcode($code);
$n = preg_match_all('#\.*\[/url\]#U', $code, $matches);
foreach($matches[0] AS $match)
{
$string = str_replace('[url]', '', $match);
$string = str_replace('', '', $string);
$html_url = '<a href="' . $string . '" target="_blank">' . $string . '</a>';
$code = str_replace($match, $html_url, $code);
}
//########## /CLICKABLE LINK HACK ###########
nerbert
10-17-2011, 01:24 PM
To do it retroactively would require a plugin in showthread.php (or a huge rebuild of your post table in the DB). If you go with a showthread plugin you won't want the hack in the bbcode file, so comment that hack out so they don't interfere with each other. I'll work on a plugin but it might be later today.
imcool2121
10-17-2011, 01:35 PM
To do it retroactively would require a plugin in showthread.php (or a huge rebuild of your post table in the DB). If you go with a showthread plugin you won't want the hack in the bbcode file, so comment that hack out so they don't interfere with each other. I'll work on a plugin but it might be later today.
would that plugin eat up lots of bandwidth mate ? bcoz my forum has more than 100,000 such threads where coded links aren't clickable.
also , i need some custom vbulletin plugin for which i can also pay. plz PM me your gtalk or skype, so we can talk on this.
thanks
this code make links in code clickable only if they are posted after today.
but it does not make those links in code clickable which have been already posted.
Maybe it's due to cached posts? If so then old ones should appear as the cached version expires, or you could try rebuilding the post cache in the ACP.
nerbert
10-17-2011, 06:03 PM
I couldn't get vB's function to work in a plugin so I used my own url detector. It may not be as robust as vB's but it's never failed yet.
I think I got this working
Product: vBulletin
Hook Location: showthread_complete
Execution order: 5 (or whatever)
if($vbulletin->userinfo['userid'] == 1)
{
ini_set('display_errors', '1');
$nc = preg_match_all('#<pre.*</pre>#U', $postbits, $matches_code);
foreach($matches_code[0] AS $match_code)
{
$match = null;
$matches = null;
$url_regex = '#https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?[^<\.,:;"\'\s]+#';
$n = preg_match_all($url_regex, $match_code, $matches);
foreach($matches[0] AS $match)
{
$html_url = '<a href="' . $match . '" target="_blank">' . $match . '</a>';
$match_string = str_replace($match, $html_url, $match_code);
}
$postbits = str_replace($match_code, $match_string, $postbits);
}
}
Change the first line to put in your own userid where you see 1. That way it will only work for you. Later if it works you can eliminate that whole conditional.
When you paste this in be sure $url_regex = ..... is all one continuous line with no spaces.
Get rid of the old hack and test the hell out of this and see what happens.
--------------- Added 1318878877 at 1318878877 ---------------
Already found a problem. Revised code:
if($vbulletin->userinfo['userid'] == 1)
{
ini_set('display_errors', '1');
$nc = preg_match_all('#<pre[\s\S]*</pre>#U', $postbits, $matches_code);
foreach($matches_code[0] AS $match_code)
{
$match = null;
$matches = null;
$url_regex = '#https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?[^<\.,:;"\'\s]+#';
$n = preg_match_all($url_regex, $match_code, $matches);
foreach($matches[0] AS $match)
{
$html_url = '<a href="' . $match . '" target="_blank">' . $match . '</a>';
$match_string = str_replace($match, $html_url, $match_code);
}
$postbits = str_replace($match_code, $match_string, $postbits);
}
}
imcool2121
10-17-2011, 06:16 PM
your hack in previous post is working now fine mate, it was cache problem i think.
all links in code tag are now clickable.
many many thanks to you... :)
I couldn't get vB's function to work in a plugin so I used my own url detector. It may not be as robust as vB's but it's never failed yet.
I think I got this working
Product: vBulletin
Hook Location: showthread_complete
Execution order: 5 (or whatever)
if($vbulletin->userinfo['userid'] == 1)
{
ini_set('display_errors', '1');
$nc = preg_match_all('#<pre.*</pre>#U', $postbits, $matches_code);
foreach($matches_code[0] AS $match_code)
{
$match = null;
$matches = null;
$url_regex = '#https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?[^<\.,:;"\'\s]+#';
$n = preg_match_all($url_regex, $match_code, $matches);
foreach($matches[0] AS $match)
{
$html_url = '<a href="' . $match . '" target="_blank">' . $match . '</a>';
$match_string = str_replace($match, $html_url, $match_code);
}
$postbits = str_replace($match_code, $match_string, $postbits);
}
}
Change the first line to put in your own userid where you see 1. That way it will only work for you. Later if it works you can eliminate that whole conditional.
When you paste this in be sure $url_regex = ..... is all one continuous line with no spaces.
Get rid of the old hack and test the hell out of this and see what happens.
--------------- Added 1318878877 at 1318878877 ---------------
Already found a problem. Revised code:
if($vbulletin->userinfo['userid'] == 1)
{
ini_set('display_errors', '1');
$nc = preg_match_all('#<pre[\s\S]*</pre>#U', $postbits, $matches_code);
foreach($matches_code[0] AS $match_code)
{
$match = null;
$matches = null;
$url_regex = '#https?://(\w*:\w*@)?[-\w.]+(:\d+)?(/([\w/_.]*(\?\S+)?)?)?[^<\.,:;"\'\s]+#';
$n = preg_match_all($url_regex, $match_code, $matches);
foreach($matches[0] AS $match)
{
$html_url = '<a href="' . $match . '" target="_blank">' . $match . '</a>';
$match_string = str_replace($match, $html_url, $match_code);
}
$postbits = str_replace($match_code, $match_string, $postbits);
}
}
--------------- Added 1318879141 at 1318879141 ---------------
Maybe it's due to cached posts? If so then old ones should appear as the cached version expires, or you could try rebuilding the post cache in the ACP.
yeah, you are absolutely right mate, it was cache problem :) now everything is ok.
--------------- Added 1318879521 at 1318879521 ---------------
hey mate,
i am currently using vbulletin 4.1.7 and i didn't find any plugin for the following task -
the plugin must be able to show the users their referral link code in their user cp.
also, in usercp, they must be able to see their all referred friends.
can you provide any plugin for this or help with this issue ?
let me know. thanks
nerbert
10-18-2011, 01:08 AM
I thought the posts in the DB had all the bbcode parsed to HTML and the bbcode parser wouldn't be used by showthread.php.
Re: plugin project, I don't have the friends feature turned on in my forum and I'm the only one who visits the dev site so not familiar with how all the stuff to do with friends works. And I don't know what you mean by "referral link code".
nerbert
08-16-2014, 12:58 AM
Here's plugin code to do it.
At hook location url_to_bbcode
$skiptaglist = str_replace('|code|', '|', $skiptaglist);
At hook locatiom url_to_bbcode_callback
$taglist .= '|\[code|\[/code';
See functions starting at line 165 in includes/functions_newpost.php
A lot cleaner than editing in a hack.
CAG CheechDogg
08-16-2014, 06:25 AM
Great stuff here you guys...always great to see you guys put in work for us !
MANY MANY THANKS!
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.