/ Published in: PHP

this method generates and returns a unique slug, given a string.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * genera uno slug unico per le ricerche e i fancy url * @param $string {string} stringa da trasformare in slug * @return $slug {string} uno slug valido (yyy-yyyyyy-yyy), appende un numero alla fine per renderlo unico */ public function __to_slug($string) { $this->alias . ".slug REGEXP" => "^($slug)(-\d+)?" ) )); // genero un url nome-slug-1 -- nome-slug-2 if($count > 0) return $slug . "-" . $count; else return $slug; }
Comments
