anonīms Posted April 1, 2012 Report Share Posted April 1, 2012 Nepieciešama funkcija, kas pārveidotu menu title, lai var izmantot kā urlu Piemēram: vecās grāmatas -> vecas-gramatas Es pat īsti keywordus nezinu pēc kā meklēt. Zinu, ka te agrāk bija, bet nevarēju atrast. Quote Link to comment Share on other sites More sharing options...
briedis Posted April 1, 2012 Report Share Posted April 1, 2012 Meklē šeit forumā topiku - noderīgas funckijas, tur atradīsi pēc "seo url" Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 1, 2012 Author Report Share Posted April 1, 2012 Es ceru, ka sapratāt, ka runa neiet par mod_rewrite, bet tīri $_POST, php pusē. Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 1, 2012 Author Report Share Posted April 1, 2012 Paldies :) function friendlyURL($string){ $string = preg_replace("`\[.*\]`U","",$string); $string = preg_replace('`&(amp;)?#?[a-z0-9]+;`i','-',$string); $string = htmlentities($string, ENT_COMPAT, 'utf-8'); $string = preg_replace( "`&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);`i","\\1", $string ); $string = preg_replace( array("`[^a-z0-9]`i","`[-]+`") , "-", $string); return strtolower(trim($string, '-')); } Quote Link to comment Share on other sites More sharing options...
briedis Posted April 1, 2012 Report Share Posted April 1, 2012 Esi drošs, ka tas strādā ar LV burtiem? Quote Link to comment Share on other sites More sharing options...
anonīms Posted April 1, 2012 Author Report Share Posted April 1, 2012 vēl nē Quote Link to comment Share on other sites More sharing options...
senters Posted April 1, 2012 Report Share Posted April 1, 2012 (edited) /*-------------------------------------------------------------------*/ /* Google SEO friendly URL's /*-------------------------------------------------------------------*/ function url_friendly($text) { $url = strtolower($text); $utf = array('ā', 'ē', 'ī', 'ū', 'č', 'ģ', 'ķ', 'ļ', 'ņ', 'ŗ', 'š', 'ž', 'Ā', 'Ē', 'Ī', 'Ū', 'Č', 'Ģ', 'Ķ', 'Ļ', 'Ņ', 'Ŗ', 'Š', 'Ž'); $ltn = array('a', 'e', 'i', 'u', 'c', 'g', 'k', 'l', 'n', 'r', 's', 'z', 'a', 'e', 'i', 'u', 'c', 'g', 'k', 'l', 'n', 'r', 's', 'z'); $url = str_replace($utf, $ltn, $url); $url = preg_replace('/\s/', '-', $url); $url = preg_replace('/[^\w\-]/', '', $url); return $url; } Ar LV burtiem viss ok. Edited April 1, 2012 by senters Quote Link to comment Share on other sites More sharing options...
daGrevis Posted April 2, 2012 Report Share Posted April 2, 2012 Paņem šo no Kohanas... http://kohanaframework.org/3.2/guide/api/URL#title Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.