Comments: Search Marker

Name:
Email:
Location:
URL:
Notify me of follow-up comments?
test on 2016-03-24:

Hi there to every body, it’s my first visit of this blog; this website carries amazing and truly good stuff for readers.

Mark Croxton on 2012-08-14:

The highlight function tries to match spaces if a double space appears in the search term. This can typically happen if the search term contains stop words like ‘and’, ‘or’ etc. Change function highlight() as follows to fix:
function highlight ($text, $words)
{
foreach ($words as $word)
{
  if (preg_match(’/^\S+$/’, $word))
  {
  $w = preg_quote($word);
  $regexp = “/($w)(?![^<]+>)/iu”;
  $replacement = ‘<span class=“marker”>\\1</span>’;
  $text = preg_replace ($regexp,$replacement ,$text);
  }
}
return $text;
}

Marc Miller on 2011-12-09:

This is a great plugin, but I found an odd quirk.

When I search for a term that has a generic word stripped out, my search results template breaks.

example search term: dogs and cats

‘and’ is stripped out by my EE 2.3.1 install, but for some reason that’s breaking my template. Search results template is super basic (not sure if this will work, but here it is):

<ol>
{exp:search:search_results}
  {exp:search_marker}
  <li>{title}
{excerpt}</li>
  {/exp:search_marker}
{/exp:search:search_results}
</ol>

EE 2.3.1
Search Marker 2.0

Jaap Murre on 2010-03-18:

One more thing: Now I look at the comments on the web page the HTML entities have been converted correctly. If you look at the text in a textarea, the unconverted HTML entities appear, as they do on my web page with results. I tried to use the PHP HTML entities functions in the highlight() function, but did not have any luck.

Oliver on 2010-03-18:

I will have a look at it later.

Jaap Murre on 2010-03-18:

Great addition to the search page.

I do encounter some problems with fields where XHTML is ‘on’. E.g., on the search page, I obtain:

The new website is still not finished. A great challenge is to integrate the existing ‘legacy’ site with the new one during the transition phase. Additionally, several new re>search> studies are being started,  for example on the effects of ‘brain training’ exercises on the structure and functioning of the brain.
(with the word ‘search’ highlighted correctly, though surrounded by ‘>’ chars).

instead of the original:

The new website is still not finished. A great challenge is to integrate the existing ‘legacy’ site with the new one during the transition phase. Additionally, several new research studies are being started, for example on the effects of ‘brain training’ exercises on the structure and functioning of the brain.

Is there an easy fix for this?

  —Jaap