Strange highlight class in search results subjects
If you check the actual topics there is nothing dodgy there:
http://www.translatum.gr/forum/index.php?topic=49571.msg197904#msg197904
http://www.translatum.gr/forum/index.php?topic=204152.msg398432#msg398432
Sorry for the delay in responding. Not sure why no-one else has bothered to reply before now :-\
Do you have a mod installed for changing the URLs into something more SEO friendly Pretty URLS? perhaps, it may be that the search is finding the class in the code to change the URL display from the CSS but it's not seen on the screen as it's background coding.
Maybe the database needs changing to UTF-8 due to foreign characters being used.
Just guesswork on my part as I've never seen anything like this before.
Yes, it is a modification to change search results.
This is from Search.php (check out the strong class="highlight">$1 bit)
// Fix the international characters in the keyword too.
$query = strtr($smcFunc['htmlspecialchars']($query), array('\\\'' => '\''));
$body_highlighted = preg_replace('/((<[^>]*)|' . preg_quote(strtr($query, array('\'' => ''')), '/') . ')/ie' . ($context['utf8'] ? 'u' : ''), "'\$2' == '\$1' ? stripslashes('\$1') : '<strong class=\"highlight\">\$1</strong>'", $body_highlighted);
$subject_highlighted = preg_replace('/(' . preg_quote($query, '/') . ')/i' . ($context['utf8'] ? 'u' : ''), '<strong class="highlight">$1</strong>', $subject_highlighted);
}
$output['matches'][] = array(
'id' => $message['id_msg'],
'attachment' => loadAttachmentContext($message['id_msg']),
'alternate' => $counter % 2,
'member' => &$memberContext[$message['id_member']],
'icon' => $message['icon'],
'icon_url' => $settings[$context['icon_sources'][$message['icon']]] . '/post/' . $message['icon'] . '.gif',
'subject' => $message['subject'],
'subject_highlighted' => $subject_highlighted,
'time' => timeformat($message['poster_time']),
'timestamp' => forum_time(true, $message['poster_time']),
'counter' => $counter,
'modified' => array(
'time' => timeformat($message['modified_time']),
'timestamp' => forum_time(true, $message['modified_time']),
'name' => $message['modified_name']
),
'body' => $message['body'],
'body_highlighted' => $body_highlighted,
'start' => 'msg' . $message['id_msg']
);
$counter++;
return $output;
}
And this from Search.template.php
foreach ($topic['matches'] as $message)
{
$str_summary .= '<a style="color: blue;" href="#goto_' . $counter . '">' . $message['subject_highlighted'] . '</a><br/>';
$str .= '<br />
<div class="quoteheader" style="margin-left: 20px;"><a href="' . $scripturl . '?topic=' . $topic['id'] . '.msg' . $message['id'] . '#msg' . $message['id'] . '">' . $message['subject_highlighted'] . '</a> ' . $txt[525] . ' ' . $message['member']['link'] . '</div>';
if ($message['body_highlighted'] != '')
$str .= '
<blockquote class="bbc_standard_quote" style="margin-left: 20px;">' . $message['body_highlighted'] . '</blockquote>';
}
I am not sure what I need to do in order to maintain the highlighting in search results but get rid of the actual text that pops up.
Known SMF bug.
Unresolvable?
It's been known for at least 2 years...
Why not just revert to the default search code? I dont see any difference in yours to normal results apart from the error in the middle.
What Mod did you use or is it a custom one off code job?
Because it wouldn't solve the problem?
This is a known bug even in stock SMF and fixing it is... interesting.
Quote from: Arantor on September 20, 2014, 08:27:24 AM
Because it wouldn't solve the problem?
This is a known bug even in stock SMF and fixing it is... interesting.
I was thinking that because his default code is way different to the forums. It is a wierd error though the way chops the actual word in half and not because of something not slashed out,
Nope, it's a known bug in SMF 2.0 and has been for at least a couple of years. I've spent time trying to fix it but I can't think of a good way to do it reliably.
Quote from: Arantor on September 20, 2014, 08:41:46 AM
Nope, it's a known bug in SMF 2.0 and has been for at least a couple of years. I've spent time trying to fix it but I can't think of a good way to do it reliably.
Headstart on 3.0? :P
Nah, it's still in 2.1.
What's happening is that it replaces the original word with <strong class="highlight">word</strong> and subsequent words end up replacing *inside* that HTML.
I have installed Sphinx, and the same bug still appears...
Quote from: Arantor on September 20, 2014, 08:48:42 AM
Nah, it's still in 2.1.
What's happening is that it replaces the original word with <strong class="highlight">word</strong> and subsequent words end up replacing *inside* that HTML.
Strange that it is so hard to fix :)