Page 1 of 1

BBcode for forum search

Posted: Thu Jun 03, 2004 5:13 pm
by scorphus
Hi Jason,

In the spirit of evolution and improvement of the forum on behalf of a better community I came into a new BBcode addition to perform a search in the forum.

The new BBcode I would like to suggest are the following, for example:

Code: Select all

їsearch]evolution and better and communityї/search]

and

їsearch=scorphus]evolution and better and communityї/search]
which are replaced by: evolution and better and community and evolution and better and community (by scorphus).

Here is a code with the regular expressions and the replacement strings:

Code: Select all

<?php
//[search]keywords[/search]
$regExp = "#\[search\](.*?)\[/search\]#si";
if (preg_match($regExp, $str, $regs)) {
	$rep = '<a href="http://forums.devnetwork.net/search.php?search_keywords=$1">$1</a>';
	$str = preg_replace($regExp, $rep, $str);
}

//[search=author]keywords[/search]
$regExp = "#\[search=(.*?)\](.*?)\[/search\]#si";
if (preg_match($regExp, $str, $regs)) {
	$rep = '<a href="http://forums.devnetwork.net/search.php?search_keywords=$2&search_author=$1">$2 (by $1)</a>';
	$str = preg_replace($regExp, $rep, $str);
}
?>
Also, you can click http://scorphus.no-ip.com/lab/bbcode/ and see a working example.

I hope it is ready to be added to the forum.

Cheers,
Scorphus.

Posted: Mon Jun 07, 2004 6:51 pm
by Deemo
that would be really useful. i like it :)

also, it would be cool if it could link to google 8O

Posted: Mon Jun 07, 2004 7:18 pm
by feyd
we already can link to google. :roll:

Posted: Tue Jun 08, 2004 1:11 pm
by Deemo
now i feel stupid lol

Posted: Tue Jun 08, 2004 1:20 pm
by feyd
it's okay.. I sometimes forget about the other features because I use the quickie most of the time. :) :lol: