![]() |
How to specifiy whole words only in results
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 |
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:
Code:
// v.1.8.7 |
Possible solution
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... |
All times are GMT -8. The time now is 01:13 AM. |
Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.