SearchHighlight using in Text/XML transformation type

Murugesan Manokaran asked on October 29, 2018 21:51

can we use SearchHighlight command inside a Text/xml transformation type?

Recent Answers


Peter Mogilnitski answered on October 29, 2018 22:27 (last edited on December 10, 2019 02:31)

This methods wraps the text of the first parameter into the tags specified by the other two parameters.

IN ASCX: <%# SearchHighlight("Hello World!","<b>","</b>")%>

In Text/XML you would need to create a simple custom macro where in you back-end code call the exact same method: CMS.DocumentEngine.Web.UI.TransformationHelper.SearchHighlight(param1, param2, param3)

But to wrap a text? you can do it with simple format string: {%String.FormatString("<b>{0}</b>",", "Hello World!")|(identity)GlobalAdministrator%}

0 votesVote for this answer Mark as a Correct answer

Rui Wang answered on October 30, 2018 19:36 (last edited on October 30, 2018 20:01)

Hey Muru, looks like SearchHighlight macro is available in K11 already. I can use this directly in Text/XML transformation.

{% SearchHighlight(HTMLEncode(StripTags(content)), "<span style='background-color: #FEFF8F'>", "</span>")%}

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.