News:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu

Strange highlight class in search results subjects

Started by spiros, December 17, 2012, 06:28:56 AM

Previous topic - Next topic

spiros


Chas Large

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.
My Modifications :)  My Forum

Please DO NOT PM me with support requests. Post the problem in the appropriate Support Board so everyone can benefit from the advice given.

spiros

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('\'' => '&#039;')), '/') . ')/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.

Arantor


spiros


Arantor


Night09

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?

Arantor

Because it wouldn't solve the problem?

This is a known bug even in stock SMF and fixing it is... interesting.

Night09

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,

Arantor

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.

Night09

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

Arantor

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.

spiros

I have installed Sphinx, and the same bug still appears...

Kindred

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.
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

spiros


Advertisement: