One of the problems I've had on my forums is that many people don't bother to change the subject line when the reply to a message, so when somebody does a search, they could wind up with 25 or 50 seemingly identical results (just with different authors and posting times).
Fortunately, it's pretty easy to modify the search_results template to show something that looks more like what you'd expect from a Google or AltaVista - complete with an excerpt from each hit - with the help of a nice little global somebody posted here for another purpose that looks something like this:
my $post_message = shift;
$post_message=~ s/^\s*//; # leading spaces
$post_message=~ s/\s*$//; # trailing spaces
$post_message=~ s/\s+/ /g; # multiple spaces
#
# Strip HTML tags
#
$post_message=~ s(<[^>]*>)()g;
$post_message=~ s(\[url.*\])()g;
$post_message=~ s(\[\/url\])()g;
$post_message=~ s(\[signature\])()g;
$post_message=~ s(\[size*\])()g;
#
return substr($post_message,0,200);
}
What this'll do is give you the first X characters of a post (in my case, I set it to 200 characters) and strip out any HTML and GForum pseudo-HTML (well, the pseudo-HTML that tends to be used in my forums, at any rate).
Now call up your search_results template. Get rid of the table stuff used for include_paging and the results loop and then change the results loop to your tastes (for example, bracket each result with paragraph tags). The key thing is:
<br /><%endif%>
(where "html_strip" is the name of your global).
You can see an example of this in action.
Fortunately, it's pretty easy to modify the search_results template to show something that looks more like what you'd expect from a Google or AltaVista - complete with an excerpt from each hit - with the help of a nice little global somebody posted here for another purpose that looks something like this:
Code:
sub { my $post_message = shift;
$post_message=~ s/^\s*//; # leading spaces
$post_message=~ s/\s*$//; # trailing spaces
$post_message=~ s/\s+/ /g; # multiple spaces
#
# Strip HTML tags
#
$post_message=~ s(<[^>]*>)()g;
$post_message=~ s(\[url.*\])()g;
$post_message=~ s(\[\/url\])()g;
$post_message=~ s(\[signature\])()g;
$post_message=~ s(\[size*\])()g;
#
return substr($post_message,0,200);
}
What this'll do is give you the first X characters of a post (in my case, I set it to 200 characters) and strip out any HTML and GForum pseudo-HTML (well, the pseudo-HTML that tends to be used in my forums, at any rate).
Now call up your search_results template. Get rid of the table stuff used for include_paging and the results loop and then change the results loop to your tastes (for example, bracket each result with paragraph tags). The key thing is:
Code:
<%if post_message%><%html_strip($post_message)%>... <br /><%endif%>
(where "html_strip" is the name of your global).
You can see an example of this in action.