Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Form Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Search routine includes html markup?


Go to End


1190 Views

Avatar
cwchong

Community Member, 13 Posts

31 January 2013 at 10:57am

The default search behaviour seems to perform a match of the search against say the "Content" field;
but the content field would contain html markup as well.

Thus this results in unexpected results when you search for terms such as "href" or "strong" where results are returned even when their meaningful content does not actually contain those terms.

Is there a way to avoid this?

I am thinking of creating a redundant "SearchContent" field in SiteTree and using onAfterWrite to duplicate the content into this field with tags stripped, and perform search on this field instead; is there another way? (Creating extra fields for each searchable dataobject will be a pita).

Thanks!