Wuu Posted June 28, 2009 Report Share Posted June 28, 2009 Ši funkcija pārveido nestandarta link tekstu par lietojamu ,bez garumzīmēm. piem Pārdošanā nonāk EA sporta spēles -> pardosana-nonak-ea-sporta-speles function clean_url($text){ $text=strtolower($text); $code_entities_match = array('ā','ē','ū','ī','š','ģ','ķ','ļ','ž','ņ',' ','--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','='); $code_entities_replace = array('a','e','u','i','s','g','k','l','z','n','-','-','','','','','','','','','','','','','','','','','','','','','','','',''); $text = str_replace($code_entities_match, $code_entities_replace, $text); return $text; } Bet kā lai atgriež to uz otru pusi lai spētu pieprasīt no php,mysql konkrētu informāciju. Ir doma pievienot kaut kādu skaitli galā vai sākuma ,bet nebūs diezko smuki ,varbūt ir kādi gatavi, labāki varianti? Quote Link to comment Share on other sites More sharing options...
bubu Posted June 28, 2009 Report Share Posted June 28, 2009 Glabā mysql'ā papildu lauku ar jau iztīrīto urli. Pēc tā tad arī meklēsi. Vai arī urlī papildu glabā unikalās atslēgas numuru un datubāzē tad meklē pēc tā: http://kkas.lv/123/pardosana-nonak-ea-sporta-speles Quote Link to comment Share on other sites More sharing options...
Maris-S Posted June 29, 2009 Report Share Posted June 29, 2009 A kāpēc būtu jāatsakās no garumzīmēm linkā? Quote Link to comment Share on other sites More sharing options...
Aleksejs Posted June 29, 2009 Report Share Posted June 29, 2009 Varbūt šī iemesla dēļ: http://php.lv/f/topic/13612-seo/page__p__106704__hl__p%C4%81rveido__fromsearch__1entry106704 Quote Link to comment Share on other sites More sharing options...
endrju Posted June 30, 2009 Report Share Posted June 30, 2009 Ar iconv un //TRANSLIT nepietika? P.S. Manuprāt, labāk ir lietot strtoupper (personīgi ir gadījies, ka tieši lielos mīkstinājuma burtus nemāk konvertēt uz lower) Quote Link to comment Share on other sites More sharing options...
torrentz Posted July 1, 2009 Report Share Posted July 1, 2009 garumzīmes labāk nevajag. es izmantoju taadu variantu: <?php function seo_string($string, $separator = '-') { $string = str_replace(array("ş", "Ş", "Ţ", "ţ", "ă", "î", "â"), array("s", "s", "t", "t", "a", "i", "a"), $string); //RO translit $string = str_replace(array("ā","č", "ē", "ģ", "ķ", "ļ", "ī", "ū", "š", "ņ", "ž"), array("a", "c", "e", "g", "k", "l", "i", "u", "s", "n", "z"), $string); //LV translit $string = str_replace(array("Ё","Ж","Ч","Ш","Щ","Э","Ю","Я","ё","ж","ч","ш","щ","э","ю","я","А","Б","В","Г","Д","Е","З","И","Й","К","Л","М","Н","О","П","Р","С","Т","У","Ф","Х","Ц","Ы","а","б","в","г","д","е","з","и","й","к","л","м","н","о","п","р","с","т","у","ф","х","ц","ь","ы"),array("JO","ZH","CH","SH","SCH","JE","JY","JA","jo","zh","ch","sh","sch","je","jy","ja","A","B","V","G","D","E","Z","I","J","K","L","M","N","O","P","R","S","T","U","F","H","C","Y","a","b","v","g","d","e","z","i","j","k","l","m","n","o","p","r","s","t","u","f","h","c","'","y"), $string); //RU translit $string = strtolower($string); $string = trim($string); $string = trim(ereg_replace("[^ A-Za-z0-9_]", " ", $string)); #$string = ereg_replace("[ tnr]+", "-", $string); $string = str_replace(" ", $separator, $string); $string = ereg_replace("[ -]+", "-", $string); return $string; } ?> un ID lieku vai nu priekšā vai pakaļā (pēc garastāvokļa), un neko lieku mysqlā glabāt negribu :) Quote Link to comment Share on other sites More sharing options...
Val Posted November 16, 2009 Report Share Posted November 16, 2009 (edited) pajautāšu tepat... ir links: http://www.kautkadalapa.lv/katalogs/101/preces-nosaukums vēlētos uzzināt, vai ir jēga pirms sūtīšanas lietotājam pārbaudīt, vai linkā sakrīt preces id ar preces nosaukumu, vai pietiks tikai ar preces id? tb, ja id nesakrīt ar nosaukumu, tad redirektējam lietotāju uz pareizo saiti, atkarībā no padotā preces id... Piemēram, atļaut vērt vaļā http://www.kautkadalapa.lv/katalogs/101/nepareizs-preces-nosaukums vai nē? Preces nosaukums nav unikāls. Uztaisīts tā, ka pēdējā daļa nav obligāta. http://www.kautkadalapa.lv/katalogs/101/preces-nosaukums http://www.kautkadalapa.lv/katalogs/101/ Abi linki atvērs vienu un to pašu lappusi. Edited November 16, 2009 by Val Quote Link to comment Share on other sites More sharing options...
marcis Posted November 16, 2009 Report Share Posted November 16, 2009 Val, pēc garstāvokļa :) Vispār es uzskatu, ka nav nekādas vajadzīgas dot līdzi divus unikālus identifikatorus. 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.