a good idea would be to apply this function not as a helper but as an inflector.
http://www.symfony-project.org/api/1_2/sfInflector On Mon, Oct 19, 2009 at 9:31 AM, Raphael <[email protected]> wrote: > I intend to use to link and filenames. and do not have much interest that > this string is unique. just need to remove the special characters. > > > On Mon, Oct 19, 2009 at 7:29 AM, Henrik Bjornskov <[email protected]>wrote: > >> >> As a slug should be unique why would you have such a function, it will >> surely make a duplicate when used on two items with the same name.. >> Besides Doctrine has an excellent Sluggable behavior >> >> On Oct 16, 4:07 pm, Raphael <[email protected]> wrote: >> > yes Pascal, my idea from slug behavior of Doctrine. but i think about a >> > helper, but your idea is great to. >> > >> > Salome, thanks for your idea. >> > >> > http://snippets.symfony-project.org/snippet/366 >> > >> > >> > >> > On Fri, Oct 16, 2009 at 10:59 AM, [MA]Pascal <[email protected]> >> wrote: >> > >> > > Hi, >> > >> > > or you can use Doctrine_Inflector::urlize(); >> > >> > > I don't think its place should be in helpers >> > >> > > Cheers >> > > [MA]Pascal >> > >> > > On Oct 16, 1:46 pm, Alexandre SALOME <[email protected]> >> > > wrote: >> > > > Post is as a snippet :http://snippets.symfony-project.org/ >> > >> > > > I think one day I will be happy to find back your function :) >> > >> > > > 2009/10/16 Raphael <[email protected]> >> > >> > > > > Its simple and util. >> > >> > > > > I have a code: >> > >> > > > > function slugString($string, $replacement = '_') >> > > > > { >> > > > > $aux = preg_quote($replacement, '/'); >> > >> > > > > $map = array( >> > > > > '/à|á|ã|â/' => 'a', >> > > > > '/è|é|ê|ẽ|ë/' => 'e', >> > > > > '/ì|í|î/' => 'i', >> > > > > '/ò|ó|ô|ø/' => 'o', >> > > > > '/ù|ú|ũ|û/' => 'u', >> > > > > '/ç/' => 'c', >> > > > > '/ñ/' => 'n', >> > > > > '/ä|æ/' => 'ae', >> > > > > '/ö/' => 'oe', >> > > > > '/ü/' => 'ue', >> > > > > '/Ä/' => 'Ae', >> > > > > '/Ü/' => 'Ue', >> > > > > '/Ö/' => 'Oe', >> > > > > '/ß/' => 'ss', >> > > > > '/[^\w\s]/' => ' ', >> > > > > '/\\s+/' => $replacement >> > > > > ); >> > >> > > > > return preg_replace(array_keys($map), array_values($map), >> $string); >> > > > > } >> > >> > > > > -- >> > > > > Raphael Almeida Araújo >> > > > > Homepage:http://sites.google.com/site/raphoxaraujo >> > >> > > > -- >> > > > Alexandre Salomé -- [email protected] >> > >> > -- >> > Raphael Almeida Araújo >> > Homepage:http://sites.google.com/site/raphoxaraujo >> >> >> > > > -- > Raphael Almeida Araújo > Homepage: http://sites.google.com/site/raphoxaraujo > -- Raphael Almeida Araújo Homepage: http://sites.google.com/site/raphoxaraujo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "symfony developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/symfony-devs?hl=en -~----------~----~----~----~------~----~------~--~---
