Advertisement:

Author Topic: Strange highlight class in search results subjects  (Read 4169 times)

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,796
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Strange highlight class in search results subjects
« on: December 17, 2012, 06:28:56 AM »
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

Offline Chas Large

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,114
  • Gender: Male
  • Running 2.0.xx on Apache.
    • chazzonjazz on Facebook
    • @https://twitter.com/ on Twitter
    • Chas Large's Site
Re: Strange highlight class in search results subjects
« Reply #1 on: January 15, 2013, 08:53:11 AM »
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.

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,796
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Strange highlight class in search results subjects
« Reply #2 on: September 19, 2014, 04:36:33 PM »
Yes, it is a modification to change search results.

This is from Search.php (check out the strong class="highlight">$1 bit)

Code: [Select]
// 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

Code: [Select]
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.

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: Strange highlight class in search results subjects
« Reply #3 on: September 19, 2014, 08:17:38 PM »
Known SMF bug.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,796
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Strange highlight class in search results subjects
« Reply #4 on: September 20, 2014, 03:45:25 AM »
Unresolvable?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: Strange highlight class in search results subjects
« Reply #5 on: September 20, 2014, 08:00:25 AM »
It's been known for at least 2 years...
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Night09

  • SMF Hero
  • ******
  • Posts: 1,940
  • Gender: Male
Re: Strange highlight class in search results subjects
« Reply #6 on: September 20, 2014, 08:14:21 AM »
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?

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: Strange highlight class in search results subjects
« Reply #7 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Night09

  • SMF Hero
  • ******
  • Posts: 1,940
  • Gender: Male
Re: Strange highlight class in search results subjects
« Reply #8 on: September 20, 2014, 08:40:32 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,

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: Strange highlight class in search results subjects
« Reply #9 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline Night09

  • SMF Hero
  • ******
  • Posts: 1,940
  • Gender: Male
Re: Strange highlight class in search results subjects
« Reply #10 on: September 20, 2014, 08:47:13 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

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: Strange highlight class in search results subjects
« Reply #11 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.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,796
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Strange highlight class in search results subjects
« Reply #12 on: January 14, 2016, 02:49:10 AM »
I have installed Sphinx, and the same bug still appears...

Offline Kindred

  • The Mean One
  • Support Specialist
  • SMF Legend
  • *
  • Posts: 58,748
  • Gender: Male
    • Kindred-999 on GitHub
Re: Strange highlight class in search results subjects
« Reply #13 on: January 14, 2016, 10:23:58 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.
Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

Offline spiros

  • Language Moderator
  • SMF Hero
  • *
  • Posts: 1,796
  • Gender: Male
  • A different point of view
    • spiros.doikas on Facebook
    • doikas on LinkedIn
    • @greektranslator on Twitter
    • Greek Translation
Re: Strange highlight class in search results subjects
« Reply #14 on: January 14, 2016, 10:31:38 AM »
Strange that it is so hard to fix :)