We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20488
    • 353 Posts
    Hi !

    I made I light modification of the file /manager/processors/save_content.processor.php in order to replace accents in case of automatic creation of aliases.

    The issue cames when a French user didn’t mention the alias while creating a page. For exemple if I choose a title like "Bonjour à la communauté ModX !" for a page, the alias would be "bonjour-la-communautmodx", which is not optimal for SEO. This modification provides the following alias "bonjour-a-la-communaute-modx".

    It could be improved for others special chars and be included directly in the following line

     $alias = strtr($alias, array(chr(196) => 'Ae', chr(214) => 'Oe', chr(220) => 'Ue', chr(228) => 'ae', chr(246) => 'oe', chr(252) => 'ue', chr(223) => 'ss'));


    ... but I don’t know every special chars... wink

    Here is the modification :

    - Open the following file : /manager/processors/save_content.processor.php
    - Find the stripAlias function (around line 561)
    - Replace this function with the following new one :

    function stripAlias($alias) {
        global $modx;
    
        if(strtoupper($modx->config['modx_charset'])=='UTF-8') $alias = utf8_decode($alias);
        $alias = strtr($alias, array(chr(196) => 'Ae', chr(214) => 'Oe', chr(220) => 'Ue', chr(228) => 'ae', chr(246) => 'oe', chr(252) => 'ue', chr(223) => 'ss'));
    	
    	/*Modification By Olivier for aliases internationalization */
    	$pattern = Array("/é/", "/è/", "/ê/", "/ç/", "/à/", "/â/", "/î/", "/ï/", "/ù/", "/ô/", "/ñ/");
        $rep_pat = Array("e", "e", "e", "c", "a", "a", "i", "i", "u", "o", "n");
        $alias = preg_replace($pattern, $rep_pat, $alias);
        /* ------------	 END OF MODIFICATION ----------------- */
    	
    	$alias = strip_tags($alias); 
        //$alias = strtolower($alias); 
    	
    	
    	
        $alias = preg_replace('/&.+?;/', '', $alias); // kill entities 
        $alias = preg_replace('/[^\.%A-Za-z0-9 _-]/', '', $alias); 
        $alias = preg_replace('/\s+/', '-', $alias); 
        $alias = preg_replace('|-+|', '-', $alias); 
    	$alias = preg_replace('|-+|', '-', $alias); 
    	
    	
    	
        $alias = trim($alias, '-'); 
        return $alias;
    }
    


    ++

    Olivier
      • 32982
      • 674 Posts
      hi oliver thanks for your work but there is a pluigin (i think) for do that and whithuut tuch the core.
      here are the link
      http://modxcms.com/forums/index.php?PHPSESSID=b3f019a4a8be841c4682efb9529ac511&topic=7374.msg66030
      hi again
        Jabiertxof (formerly XYZVISUAL)
        My bussines: http://marker.es
        https://www.youtube.com/user/jabiertxof/videos