We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36613
    • 328 Posts
    is there a way to remove special characters by the alias of a resource on modx? My clients often write page titles titles with special characters that become like this url www.mysite.it / trdfèèàèfdà-èàììdsf
    I wish that were the catatteri specili converititi or removed and that possible?
      • 3749
      • 24,544 Posts
      It should be possible with a plugin attached to OnBeforeDocFormSave.

      You might try this:

      <?php
      
      function slugify($string) {
          $string = transliterator_transliterate("Any-Latin; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();", $string);
          $string = preg_replace('/[-\s]+/', '-', $string);
          return trim($string, '-');
      
      $pageAlias = $resource->get('pagetitle');
      $resource->set('alias', slugify($pageAlias));
      
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting