How to make codded link clickable

Status
Not open for further replies.

exiles

Active Member
260
2008
0
5
Hello Guys.

May I know how to make a link clickable inside code or quote bbcode.
right now if we post link under code or quote, the link is not clickable.

maybe there is easy way I dont know. I want by default entering links inside code and quote will convert them into working links.

89921541226448329521.png
 
26 comments
That won't work, phpBB does not parse anything inside code BBCodes unless it is direct HTML :P Which is what mine does ;)

There is another way, modifying the php code ;)

Here's :P

OPEN: includes/message_parser.php

FIND:
PHP:
return '[code:' . $this->bbcode_uid . ']' . $this->bbcode_specialchars($code) . '[/code:' . $this->bbcode_uid . ']';

REPLACE WITH:
PHP:
$str_from = array('<', '>', '[', ']', '.', ':');
				$str_to = array('<', '>', '[', ']', '.', ':');
				
				$lines_code = str_replace("\n" , ' /\ ', $this->bbcode_specialchars($code));
				
				$exploded_code = explode(' ', $lines_code);
				
				foreach ($exploded_code as $v)
				{
					if (!$v == '/\\')
					{
						if (preg_match('#^' . get_preg_expression('url') . '$#i', str_replace($str_from, $str_to, $v)) || preg_match('#^' . get_preg_expression('www_url') . '$#i', str_replace($str_from, $str_to, $v)) || preg_match('#^' . preg_quote(generate_board_url(), '#') . get_preg_expression('relative_url') . '$#i', $url))
						{
							str_replace($v, '<a href="$v">$v</a>', str_replace($str_from, $str_to, $lines_code));
						}
					}
				}
				
				$code = str_replace(' /\ ', "\n", $lines_code);
				
				return '[code:' . $this->bbcode_uid . ']' . $code . '[/code:' . $this->bbcode_uid . ']';

Credits to me :D

Untested ;)
 
Status
Not open for further replies.
Back
Top