API
Version 7.x > API > SeachHighlight: Problem with HTML-field View modes: 
User avatar
Member
Member
magnus-tenk - 11/5/2012 6:50:24 PM
   
SeachHighlight: Problem with HTML-field
Hi. I don't know if this is the expected behaviour or perhaps an unnescessary limitation of this function, but when I feed it with a HTML-string, it performs a HTMLEncode on it, so that the html get rendered as text, with the exception of the Highlight-tag.

I would appreciate some input on this.

/Magnus

To give an example.
I give:
SearchHighLight("My <strong> html </strong> word etc...", startTag, stopTag)
I want:
My <strong> html </strong> <span class"highLight"> word </span> etc..
I get:
"My <strong> html </strong>" <span class"highLight"> word </span> "etc.."

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 11/5/2012 7:48:13 PM
   
RE:SeachHighlight: Problem with HTML-field
Hello,

This behavior is by design. You can create a custom function (custom transformation function if you are using it in the transformation) for highlighting, which will keep the html tags in place.

Best regards,
Boris Pocatko

User avatar
Member
Member
magnus-tenk - 11/12/2012 5:10:00 PM
   
RE:SeachHighlight: Problem with HTML-field
I followed your advice and have a working html-highlighter now, after some regex-hacking. I really appreciate the extensibility of Kentico.