MyBB Community Forums

Full Version: Links in posts
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I would like to change standard parsing of links. When somebody post any link (with www, http), parser will colour this, but not create active link.
And another: how to change parsing, when somebody posts a link to our forum and I would like a link with title from forum. For example:

I write here: http://community.mybboard.net/showthread.php?tid=24297
but after I post - link looks like:
Portal Mod like Tiny Portal

Any ideas to do this things?
I don't understand your first request.
For example, if the user enters:
[url=http://example.com/]Example website[/url]
what results do you want?


For the second, you can do something like this:

In inc/class_parser.php,
Find:
if(!preg_match("#[a-z0-9]+://#i", $fullurl))
		{
			$fullurl = "http://".$fullurl;
		}
After, add:
		global $mybb;
		if(!$name && !preg_replace('#'.preg_quote($mybb->settings['bburl'].'/showthread.php?tid=').'([0-9]+?)#', '', $fullurl))
		{
			$tid = intval(preg_replace('#'.preg_quote($mybb->settings['bburl'].'/showthread.php?tid=').'([0-9]+?)#', '$1', $fullurl));
			global $db;
			$name = $db->fetch_field($db->simple_select(TABLE_PREFIX.'threads', 'subject', 'tid='.$tid), 'subject');
		}

Note that the above code is rather "slow" as it performs a query per link found. It can be optimized to only perform one query in total, but it does take more work.

Also, I haven't tested the code so can't confirm that it works.

Also take note of the following:
  • It's based on the setting of your URL in your AdminCP - for example, if you set the board URL to be "http://example.com", links such as "http://www.example.com/showthread.php?tid=222" won't work
  • Also, if there's some extra arguments in the URL, eg "&page=1" etc, it won't work either
I release first thing Smile

In inc/class_parser.php:

Find this
$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";

Replace with
$link = "<font color=\"#008080\">$fullurl</font>";

#008080 colour is example Smile Now i don't have any active links in posts.

ZiNga BuRgA: Your code didn't work...
I was need the 2nd request you ask for too. thanks ZiNga BuRgA for your try
please whene you got a time, make a perfect one for us.

DamYan Wrote:I release first thing Smile

In inc/class_parser.php:

Find this
$link = "<a href=\"$fullurl\" target=\"_blank\">$name</a>";

Replace with
$link = "<font color=\"#008080\">$fullurl</font>";

#008080 colour is example Smile Now i don't have any active links in posts.

that will work as you want, but it can done with editing postbit template, and little css code
but both will work