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
How to highlight the keyword in search result
Moderator: mkoch227
-
- Posts: 94
- Joined: Wed Feb 29, 2012 2:00 am
How to highlight the keyword in search result
Eagle
Life is a journey.
Life is a journey.
-
- Posts: 94
- Joined: Wed Feb 29, 2012 2:00 am
Re: How to highlight the keyword in search result
I added some lines to make it work for kb suggestion.
suggest_articles.php
in line 88 before echo '
add 4 lines:
then change the line after echo '
fromto
That's done.
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']);
from
Code: Select all
<a href="knowledgebase.php?article='.$article['id'].'&suggest=1" target="_blank">'.$article['subject'].'</a>
<br />'.$txt.'<br /><br />';
Code: Select all
<a href="knowledgebase.php?article='.$article['id'].'&suggest=1" target="_blank">'.$highsubject.'</a>
<br />'.$hightxt.'<br /><br />';
Eagle
Life is a journey.
Life is a journey.
-
- Posts: 94
- Joined: Wed Feb 29, 2012 2:00 am
Re: How to highlight the keyword in search result
it also work for kb search, alsmost same.
knowledgebase.php
line 240
after
add 4 lines
then change the subject and txt just few lines after
from
to
from
to
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
knowledgebase.php
line 240
after
Code: Select all
{
$txt = substr(strip_tags($article['content']),0,$hesk_settings['kb_substrart']).'...';
}
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']);
from
Code: Select all
<td valign="top"><a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a></td>
Code: Select all
<td valign="top"><a href="knowledgebase.php?article='.$article['id'].'">'.$highsubject.'</a></td>
Code: Select all
<td><span class="article_list">'.$txt.'</span></td>
Code: Select all
<td><span class="article_list">'.$hightxt.'</span></td>
Eagle
Eagle
Life is a journey.
Life is a journey.
Re: How to highlight the keyword in search result
Thanks for sharing.
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here 
You should follow me on Twitter here
Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools


Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...
Also browse for php hosting companies, read php books, find php resources and use webmaster tools