Add transliteration slug (friendly url)
Posted: Tue Sep 29, 2015 7:47 am
Hi Diego! Can you adding auto transliteration for slug (friendly url)?
Code: Select all
public static function cleanUrl($string, $separator='-')
{
if(function_exists('iconv')) {
$string = iconv('UTF-8', 'ASCII//TRANSLIT', $string);
}
$string = preg_replace("/[^a-zA-Z0-9\/_|+ -]/", '', $string);
$string = trim($string, '-');
$string = self::lowercase($string);
$string = preg_replace("/[\/_|+ -]+/", $separator, $string);
return $string;
}
iconv is installed, see the phpinfo http://bludit.ml/phpinfo.phpdiego wrote:Hi voro,
it implemented, I used iconv (http://php.net/manual/en/book.iconv.php), may be you don't have installed this module.
You have your own server ?
Good works only character mapdiego wrote:Yes I saw the problem.. I am searching a solution for it, have you some recomendation ? thanks
Code: Select all
array (
'А'=>'a','Б'=>'b','В'=>'v',
'Г'=>'g','Д'=>'d','Е'=>'e','Ё'=>'yo','Ж'=>'zh',
'З'=>'z','И'=>'i','Й'=>'j','К'=>'k','Л'=>'l',
'М'=>'m','Н'=>'n','О'=>'o','П'=>'p','Р'=>'r',
'С'=>'s','Т'=>'t','У'=>'u','Ф'=>'f','Х'=>'h',
'Ц'=>'c','Ч'=>'ch','Ш'=>'sh','Щ'=>'shh','Ъ'=>'',
'Ы'=>'y','Ь'=>'','Э'=>'e','Ю'=>'yu','Я'=>'ya',
'а'=>'a','б'=>'b','в'=>'v','г'=>'g','д'=>'d',
'е'=>'e','ё'=>'yo','ж'=>'zh','з'=>'z','и'=>'i',
'й'=>'j','к'=>'k','л'=>'l','м'=>'m','н'=>'n',
'о'=>'o','п'=>'p','р'=>'r','с'=>'s','т'=>'t',
'у'=>'u','ф'=>'f','х'=>'h','ц'=>'c','ч'=>'ch',
'ш'=>'sh','щ'=>'shh','ъ'=>'','ы'=>'y','ь'=>'',
'э'=>'e','ю'=>'yu','я'=>'ya',' '=>'-','-'=>'-','»'=>''
);
All works fine, thank!diego wrote:Done, after a while searching a better solution on Google, I used the array with the characters.
Please download the version from Github and let me know if there are some error.
thanks