Jump to:

22983 Posts in 11719 Topics by 2827 members

General Questions

SilverStripe Forums » General Questions » Write & search content having special characters like german umlauts

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 2189 Views
  • weberho
    Avatar
    Community Member
    15 Posts

    Write & search content having special characters like german umlauts Link to this post

    I found a posting of a user who had problems to search umlauts within a silverstripe page. The problem comes from a setting which should be set in the tinymce configuration. Without this configuration directive tinymce will alway replace umlauts lik 'Ãœ' with their aeuivalent 'Ü' The search tool later on expects to read UTF-8 and can not find the content or displays the content double encoded (here: Ü) in the results list.

    Attached you can find a patch which solves this problem. After applying the patch you have to to a /db/build?flush=1 and save all pages containing umlauts in the content again.

    Best regards,
    Johannes

    Index: SilverStripe/cms/javascript/tinymce.template.js
    ===================================================================
    --- SilverStripe/cms/javascript/tinymce.template.js   (revision 5774)
    +++ SilverStripe/cms/javascript/tinymce.template.js   (working copy)
    @@ -40,6 +40,7 @@
          safari_warning : false,
          relative_urls : true,
          verify_html : true,
    +      entity_encoding : "raw",
          valid_elements : "+a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],-td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-div[id|dir|class|align],-span[class|align],-pre[class|align],address[class|align],-h1[id|dir|class|align],-h2[id|dir|class|align],-h3[id|dir|class|align],-h4[id|dir|class|align],-h5[id|dir|class|align],-h6[id|dir|class|align],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir]",
          extended_valid_elements : "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name]"
       });

  • tobych
    Avatar
    Community Member
    97 Posts

    Re: Write & search content having special characters like german umlauts Link to this post

    Wouldn't it make more sense to leave the saved data alone and, instead, convert special characters in the search term into HTML entities before doing the search? Just a thought.

  • weberho
    Avatar
    Community Member
    15 Posts

    Re: Write & search content having special characters like german umlauts Link to this post

    As silverstripe is fully utf-8 enabled, there is no need to encode any characters in a special way. Only for html-output purposes the &, < and > characters in text sections must be html-encoded (otherwise the browsers would try to interpret them as html-elements). That's exactly what the setting does (see http://wiki.moxiecode.com/index.php/TinyMCE:Configuration/entity_encoding ).

    Storing ans searching works nicely with the patch, and users should be able to handle content in all charactersets without any workarounds.

    Johannes

  • akimo
    Avatar
    Community Member
    3 Posts

    Re: Write & search content having special characters like german umlauts Link to this post

    @weberho:

    thank you for the tipp. As Silverstripe uses its own configuration, you can set such config vars in the "HtmlEditorConfig"-Class (sapphire/forms/HtmlEditorConfig.php). All settings are defined in the protected property "$settings". They will be packed and sent to the browser.

    Note and Question: Its not good style to edit lib-files, because you will get some trouble to upgrade to newer Versions. Is there a chance not to edit a lib file, and create a project related configuration?

  • weberho
    Avatar
    Community Member
    15 Posts

    Re: Write & search content having special characters like german umlauts Link to this post

    you are right, but it's the only way I have found to handle that issue; I have opened a ticket http://open.silverstripe.org/ticket/3582 suggesting to set that as default for future releases...

    Johannes

    2189 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.