View Full Version : How to specifiy whole words only in results
schizmat
03-14-2005, 12:47 AM
Hello
Is it possible to configure/specify that the search results text only contains full words rather than partial or truncated words?
For example, a current client site under development returns:
...od practice...
when the client would prefer to see:
...good practice...
Apologies if I've missed something obvious in the docs/forum, but there you go.
Jak/Schizmat
Charter
03-15-2005, 09:39 AM
The following code, and possibly related code, would need to be modified in search_functions.php to cut on a space rather than take a substring:
// v.1.8.7
$extract_content = substr($extract_content,$first_bold_spot,max(SNIPPET_DISPLAY_LENGTH, 2 * strlen($query_string)));
// v.1.8.8 RC1
$extract_content = mb_substr($extract_content,$first_bold_spot,$length_of_snip);
schizmat
03-21-2005, 02:16 AM
Probably not the most elegant solution but, I added a line which seems to work:
$extract_content = substr($extract_content,$first_bold_spot,max(SNIPPET_DISPLAY_LENGTH, 2 * strlen($query_string)));
//addition begins:
$extract_content = substr($extract_content, strpos($extract_content, " ", 0) + 1, strrpos($extract_content, " ") - strpos($extract_content, " ", 0));
//addition ends
$extract .= ' ...'.phpdigHighlight($reg_strings,$extract_content).'... ';
This is in the search_function.php file only. As it works at the point of result output, I don't _think_ I need to change anything else?
(I've increased snippet length to help with the context, but knowing this particular client I doubt they'll be happy anyway! *shrugs)
Hope this is of use to someone. I guess that wrapping the line in an if statement and adding a config flag could allow this to be easily turn on and offable if it's a useful enough option...
vBulletin® v3.7.3, Copyright ©2000-2025, Jelsoft Enterprises Ltd.