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.

Archive /

Our old forums are still available as a read-only archive.

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

Site Search - German Site - Problem with Umlaut


Go to End


10 Posts   6539 Views

Avatar
JimAasheim

Community Member, 12 Posts

10 November 2008 at 1:02am

Edited: 10/11/2008 1:58am

Any solution by now?

Generally the search works fine.
With umlaute the previously described "no results" occurs.
However, when you search for the word "möchten" but type "möchten" the search does get the results that contain the word.

I wonder how the data is stored in the database and if the query parameters need to convert characters to html entities before executing the query and also to convert back to correct HTML to get the umlaute issue solved?

Hint: I'm running SS 2.2.3

Executing the sql query "select id, content from SiteTree limit 10;" from shell (not phpMyAdmin) I get confirmed what was written before: the database contains plain HTML code:
<h4>Pflege ist Dienstleistung, </h4> <p>&ouml;de ist langweilig</p>

So I would need to convert the search term using htmlentities() before passing it to the query.

Here is what I did (and it's working):
changed line 76 in sapphire/search/SearchForm.php from

75 public function getResults($numPerPage = 10){
76 $keywords = $_REQUEST['Search'];

into

75 public function getResults($numPerPage = 10){
76 $keywords = htmlentities($_REQUEST['Search'], ENT_QUOTES, 'UTF-8');

For the results I used the following in Page_Results.ss template:
<!-- do some decoding here to display results with umlaute etc. correctly -->
<p>$Content.LimitWordCount</p>

Avatar
Ingo

Forum Moderator, 801 Posts

10 November 2008 at 4:43am

Thanks for your patch and ideas, Jim! The problem is that we'd break special character searches in all other (unescaped) fields like "Title". There's two existing tickets with partial patches for the problem, we need somebody to write unit tests for the existing functionality before we can proceed with making the searchform i18n-compatible. Shouldn't be too hard, the groundwork is done in the patch. Anyone keen?

http://open.silverstripe.com/ticket/2267
http://open.silverstripe.com/ticket/2363

Go to Top