Page 1 of 1
How to highlight the keyword in search result
Posted: Tue Mar 20, 2012 1:44 am
by deserteagle369
Script URL:
Version of script:
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:
Write your message below:
Highlight the keyword in kb suggestion or search result make it easy to read, how to do it?
Thanks,
Eagle
Re: How to highlight the keyword in search result
Posted: Tue Mar 20, 2012 3:23 am
by deserteagle369
I added some lines to make it work for kb suggestion.
suggest_articles.php
in line 88 before echo '
add 4 lines:
Code: Select all
$high = $query;
$repl = '<span style="background-color:yellow">' . $high . '</span>';
$hightxt = str_ireplace($high, $repl, $txt);
$highsubject = str_ireplace($high,$repl,$article['subject']);
then change the line after echo '
from
Code: Select all
<a href="knowledgebase.php?article='.$article['id'].'&suggest=1" target="_blank">'.$article['subject'].'</a>
<br />'.$txt.'<br /><br />';
to
Code: Select all
<a href="knowledgebase.php?article='.$article['id'].'&suggest=1" target="_blank">'.$highsubject.'</a>
<br />'.$hightxt.'<br /><br />';
That's done.
Re: How to highlight the keyword in search result
Posted: Tue Mar 20, 2012 3:55 am
by deserteagle369
it also work for kb search, alsmost same.
knowledgebase.php
line 240
after
Code: Select all
{
$txt = substr(strip_tags($article['content']),0,$hesk_settings['kb_substrart']).'...';
}
add 4 lines
Code: Select all
$high = $query;
$repl = '<span style="background-color:yellow">' . $high . '</span>';
$hightxt = str_ireplace($high, $repl, $txt);
$highsubject = str_ireplace($high,$repl,$article['subject']);
then change the subject and txt just few lines after
from
Code: Select all
<td valign="top"><a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a></td>
to
Code: Select all
<td valign="top"><a href="knowledgebase.php?article='.$article['id'].'">'.$highsubject.'</a></td>
from
Code: Select all
<td><span class="article_list">'.$txt.'</span></td>
to
Code: Select all
<td><span class="article_list">'.$hightxt.'</span></td>
For the admin page, kb search is in knowledgebase_private.php, so you need change it also, then duplicate knowledgebase_private.php to knowledgebase.php again.
Eagle
Re: How to highlight the keyword in search result
Posted: Tue Mar 20, 2012 4:44 pm
by Klemen
Thanks for sharing.