Page 1 of 1

"search highlight plugin" ...gone?

Posted: Thu Sep 21, 2006 6:10 pm
by sph
hi folks!

umm, i added a search-function to my blog and now i want to highlight the search keywords - maybe with customized colors.

i found some discussion here about a "search highlight plugin" which maybe would be what i want - but i can't find this or something similar at the plugins-list o_0

so, is there something similar? or do i have to get this plugin elswhere?

any help welcome ( ;) ),

cheers&beers!



edit: aaah, not to be missunderstood: i don't want to highlight the search-text entered at google or those websearches.

i do want to highlight the search text entered at my blog-search. is this possible?

Posted: Thu Sep 21, 2006 7:56 pm
by carl_galloway
great concept it would be awesome if that could be added. I've asked in the past if we could change the search results so that instead of seeing the entry body we actually see a snippet of the entry around where the search term appears. Garvin mentioned that this would take a lot of system resources on the server and might not be a good idea, but your idea could work. We already place a <span> around the search term in the serendipity message that says how many searcfh results there are, so it might not be too difficult to do the same thing inside the entry. Maybe one of the developers could let us know how easy this would be.

If they can make it work, then we would just need to add some css styling to the search term so that it appears highlighted.

Posted: Fri Sep 22, 2006 4:54 pm
by sph
so - this means there is no such function right now, right?

damn, i thought so :)


meanwhile i found this "search highlight plugin" - of course this plugin is still where it sould be. but it's not working for my purposes.

but maybe someone able to code stuff could use this highlight-plugin and check out how it works? and then use this function as a seperate plugin for the blog-intern search terms?

don't know how hard this is. just would be nice, i guess :)

i love your idea of having a span (maybe span&id, class or sth...) around the search terms. would be exactly what i thought about! :)

your mentioned snipped-function would be nice, also - but this sounds really a little more complicated. i guess a simple highlight would be easier. at least i hope so ;)


---
edit: this forum is... strange. should i contact my isp or is really something wrong here? loading-times are horrible...

Posted: Fri Sep 22, 2006 5:17 pm
by judebert
My computer must have rebooted while I wrote my reply. I think this can be implemented with a change to serendipity_printEntries(). I'd just check if $serendipity['action'] == 'search', then explode($serendpity['GET']['searchterms'] on space, and do a str_replace() for each term to surround it with a span. I'd make the spans have two classes: foundterm and foundtermN, where N is the number of the term. That way we can highlight the first term in yellow, the second in blue, etc -- but still have a catch-all if the style doesn't cover all the search terms.

I just don't know when I'll get to it.

Posted: Fri Sep 22, 2006 11:26 pm
by sph
judebert wrote:My computer must have rebooted while I wrote my reply.
so, in memory of the origin posting - r.i.p. ;)
judebert wrote: I think this can be implemented with a change to serendipity_printEntries(). I'd just check if $serendipity['action'] == 'search', then explode($serendpity['GET']['searchterms'] on space, and do a str_replace()...
whatever you're talking about - does this mean it is possible without bigger problems? wel, we'll see :)

Posted: Sat Sep 23, 2006 3:12 pm
by judebert
Yes, it should be something I can implement without too much trouble. It's just a matter of finding the time...

Posted: Wed Sep 27, 2006 4:36 am
by judebert
Okay, I think I've got it. I just put it in SVN on berlios.de. Give it a try and warn me if I messed anything up.