Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Query for search done in vanilla forums
when i search something in vanilla forums, can it be made possible that the search items returned are highlighted with the query text used ?
Tagged:
0
Answers
Sorry this might be old post but I thought I would share. You can do this. First you need to have the search files in you theme folder, it is better behavior. Open the the results.php file and put the following function at the top:
function search_excerpt_highlight($excerpt, $keywords) { $keys = implode('|', explode(' ', $keywords)); $excerpt = preg_replace('/(' . $keys .')/iu', '<strong class="search-highlight">\0</strong>', $excerpt); return($excerpt); }
Then replace this:
SliceString(Gdn_Format::Text($Row->Summary, FALSE), 250);
by this:
Then you can use css to style the strong.search-highlight elements.
If you re going to do it hat way, at least copy it over to you theme, otherwise it is likely to get overwiten. Better still do it is plugin with hooks. Or non invasive javascript, for optimal performance.
grep is your friend.
Yes definitely.