We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31906
    • 26 Posts
    Hello,

    I turned on automatic generation of URL aliases and it keeps accents in alias. For example:
    Page name: ášč
    Alias: ášč

    Is it possible to set somehow behaviour where accents would be removed? Like:
    Page name: ášč
    Alias: asc

    Thanks for help!
      • 34123
      • 103 Posts
      I have this issue too if i use this character ":" or "é"

      I have to rename my Alias to something more server friendly

      Frost
        Configuration Apache + Modx + MSSQL 2008
        ===============================
        Apache/2.4.3 (Win32) OpenSSL/1.0.1c PHP/5.4.8
        OS : Windows 2008 R2
        SGBDR : Microsoft SQL Server 2008 (express)
        • 24865
        • 289 Posts
        The modified pattern I use will remove ’:’, ’.’, and ’!’ as well. I’ll look into the plain characters. Don’t know if it’s possible tho.

        /[\0\x0B\t\n\r\f\a&=+%#<>"~`@\:\!\.\?\[\]\{\}\|\^\'\\\\]/
          @MarkGHErnst

          Developer at Adwise Internetmarketing, the Netherlands.
          • 24865
          • 289 Posts
          I’ve created a little hack (I guess?) since there are no plugin events near the function we need.

          File: modresource.class.php
          Directory: /root/core/model/modx/
          Near line: ~327/330
          Instructions: Copy the entire portion of the script in the code area beneath the switch’s case break at line ~327.

                      case 'alphanumericpattern': // Custom addon
                      	/* restrict alias using regular expression pattern configured (same as legal by default) */
                          if (!empty($restrictcharspattern)) {
          					$alias = preg_replace($restrictcharspattern, '', $alias);
          				}
          				
          				$accents = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý',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'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
          				
          				$alias = str_replace($accents, $replacements, $alias); 
                      	break;


          Your script should now look something like this:
                      case 'legal':
                          /* restrict alias to legal URL characters only */
                          $alias = preg_replace('/[\0\x0B\t\n\r\f\a&=+%#<>"~`@\?\[\]\{\}\|\^\'\\\\]/', '', $alias);
                          break;
                      case 'alphanumericpattern': // Custom addon
                      	/* restrict alias using regular expression pattern configured (same as legal by default) */
                          if (!empty($restrictcharspattern)) {
          					$alias = preg_replace($restrictcharspattern, '', $alias);
          				}
          				
          				$accents = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'Æ', 'Ç', 'È', 'É', 'Ê', 'Ë', 'Ì', 'Í', 'Î', 'Ï', 'Ð', 'Ñ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'Ù', 'Ú', 'Û', 'Ü', 'Ý', 'ß', 'à', 'á', 'â', 'ã', 'ä', 'å', 'æ', 'ç', 'è', 'é', 'ê', 'ë', 'ì', 'í', 'î', 'ï', 'ñ', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'ù', 'ú', 'û', 'ü', 'ý', 'ÿ', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ď', 'ď', 'Đ', 'đ', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'IJ', 'ij', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Œ', 'œ', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'ſ', 'ƒ', 'Ơ', 'ơ', 'Ư', 'ư', 'Ǎ', 'ǎ', 'Ǐ', 'ǐ', 'Ǒ', 'ǒ', 'Ǔ', 'ǔ', 'Ǖ', 'ǖ', 'Ǘ', 'ǘ', 'Ǚ', 'ǚ', 'Ǜ', 'ǜ', 'Ǻ', 'ǻ', 'Ǽ', 'ǽ', 'Ǿ', 'ǿ');
          				$replacements = array('A', 'A', 'A', 'A', 'A', 'A', 'AE', 'C', 'E', 'E', 'E', 'E', 'I', 'I', 'I', 'I', 'D', 'N', 'O', 'O', 'O', 'O', 'O', 'O', 'U', 'U', 'U', 'U', 'Y', 's', 'a', 'a', 'a', 'a', 'a', 'a', 'ae', 'c', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'n', 'o', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u', 'y', 'y', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'IJ', 'ij', 'J', 'j', 'K', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'l', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'O', 'o', 'O', 'o', 'O', 'o', 'OE', 'oe', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 's', 'f', 'O', 'o', 'U', 'u', 'A', 'a', 'I', 'i', 'O', 'o', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'A', 'a', 'AE', 'ae', 'O', 'o');
          				
          				$alias = str_replace($accents, $replacements, $alias); 
                      	break;
                      case 'pattern':
                      default:


          Finished? Go to your system settings in the MODx Manager under "System" » "System Settings". Choose the tab "Filter by area" and tick "Friendly URL". You should get about 15 settings now. Find the key "friendly_alias_restrict_chars" and replace the value with "alphanumericpattern". (before it could’ve read ’pattern’, ’legal’, ’alpha’ or ’alphanumeric’). To do this, right click the line, click update or double click the value field in the list.

          This ’hack’ has not been tested to the limit and I take no responsibility if your MODx version becomes unstable. I’ve implemented this fix myself and so far I’ve not encountered any problems.
            @MarkGHErnst

            Developer at Adwise Internetmarketing, the Netherlands.
            • 22303 MODX Staff
            • 10,725 Posts
            Guys, all of this is configurable through system settings and requires absolutely no plugins or hacks. You can specify your own functions for alias transliteration. A little patience, and we’ll get it documented better for you, but this should require absolutely no changes to the code; if it does, it has failed it’s purpose and needs a JIRA ticket.
              • 24865
              • 289 Posts
              I wasn’t up to speed on this option. As for now, I will use this one, but of course I will use the native function once is will be documented. Are we going to get a full documented version aside from the current one?
                @MarkGHErnst

                Developer at Adwise Internetmarketing, the Netherlands.
                • 31906
                • 26 Posts
                I’ve written transliteration as service I hope it’s the way it should be written.

                Extract zip in attachment to your modx installation and set these system options:
                friendly_alias_translit = [noaccents | russian]
                friendly_alias_translit_class = translit.modTransliterate

                Both transliteration tables are get from Evolution. Table noaccents is modified common table. Some chars have been added.
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: waky at Aug 07, 2010, 04:19 AM

                  I’ve written transliteration as service I hope it’s the way it should be written.

                  Extract zip in attachment to your modx installation and set these system options:
                  friendly_alias_translit = [noaccents | russian]
                  friendly_alias_translit_class = translit.modTransliterate

                  Both transliteration tables are get from Evolution. Table noaccents is modified common table. Some chars have been added.
                  Awesome; thanks for the contribution to the community waky. I’ll take a look and provide some feedback soon.
                    • 24865
                    • 289 Posts
                    Not yet sure how to implement this, but thanks for your contribution mate, much appreciated!

                    /edit
                    Nevermind, as easy as 1-2-3. Seriously. I’ve fixed the resource class from MODx and implemented the translit class. As he said, in the core/components dir. Now i’ve got:
                    friendly_alias_restrict_chars			pattern
                    friendly_alias_restrict_chars_pattern 		/[\0\x0B\t\n\r\f\a&=+%#<>"~`@\:\!\.\,\?\[\]\{\}\|\^\'\\\\]/
                    friendly_alias_max_length			0
                    friendly_alias_strip_element_tags		Yes
                    friendly_alias_translit				noaccents
                    friendly_alias_translit_class			translit.modTransliterate
                    friendly_alias_trim_chars			/.-_

                    The fixed pattern also comma’s. Not that you would ever use them - really, but it does it non the less.
                      @MarkGHErnst

                      Developer at Adwise Internetmarketing, the Netherlands.
                      • 31906
                      • 26 Posts
                      Quote from: ReSpawN at Aug 10, 2010, 07:19 AM

                      Not yet sure how to implement this, but thanks for your contribution mate, much appreciated!

                      You need just do what I wrote above. And try save some document after that and look if the alias is generated OK. If it’s not working let me know.