Jump to:

5450 Posts in 1672 Topics by 1197 members

Customising the CMS

SilverStripe Forums » Customising the CMS » pretty URLs with Titles with special chars (slovak, czech, german...)

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

Page: 1
Go to End
Author Topic: 1109 Views
  • pali
    Avatar
    Community Member
    33 Posts

    pretty URLs with Titles with special chars (slovak, czech, german...) Link to this post

    update sapphire/javascript/UpdateURL.js like this:

    Add function

    function deLocalize( inStr ) {

    var outStr = inStr;
    outStr = outStr.replace(/[áÁ]/g, 'a');
    outStr = outStr.replace(/[éÉ]/g, 'e');
    outStr = outStr.replace(/[íÍ]/g, 'i');
    outStr = outStr.replace(/[ýÝ]/g, 'y');
    outStr = outStr.replace(/[óÓ]/g, 'o');
    outStr = outStr.replace(/[úÚ]/g, 'u');
    outStr = outStr.replace(/[ôô]/g, 'o');
    outStr = outStr.replace(/[ää]/g, 'a');
    outStr = outStr.replace(/[ůů]/g, 'u');
    outStr = outStr.replace(/[ěĚ]/g, 'e');
    outStr = outStr.replace(/[Å¡Å ]/g, 's');
    outStr = outStr.replace(/[čČ]/g, 'c');
    outStr = outStr.replace(/[řŘ]/g, 'r');
    outStr = outStr.replace(/[ťŤ]/g, 't');
    outStr = outStr.replace(/[žŽ]/g, 'z');
    outStr = outStr.replace(/[ľĽ]/g, 'l');
    outStr = outStr.replace(/[ĺĹ]/g, 'l');
    outStr = outStr.replace(/[ďĎ]/g, 'd');
    outStr = outStr.replace(/[ňŇ]/g, 'n');
    return outStr;
    }

    and replace

    var newSuggestion = urlSegmentField.suggestNewValue( this.value.toLowerCase() );

    with

    var newSuggestion = urlSegmentField.suggestNewValue( deLocalize(this.value.toLowerCase()) );

    Above chars are special for slovak or czech languages...

    Enjoy

    Pali

    1109 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.