RE: [SMARTY] modifiers functions
[email protected] ("Nayra Quesada")
| Newsgroups | php.smarty.dev |
|---|---|
| Message-ID | <[email protected]> |
It seems not to work so. If variable is less than 20 characters, truncate don't modify it, but if it is more than 20, then truncate cut it and add " ". I need a function that modifies my variable when its length is less than 20 charaters and adds space characters to make its length 20 characters. :-) -----Mensaje original----- De: Pedro Vera [mailto:[email protected]] Enviado el: domingo, 13 de marzo de 2005 1:07 Para: Nayra Quesada Asunto: Re: [SMARTY] modifiers functions The truncate function lets you add spaces as padding so it is 20 characters long, isn't that what you want? {$myvariable|truncate:20:" "} Will take $myvariable, if it is less than 20 characters it will add one space at a time til it adds up to 20. If it is more than 20 it will cut it at 20. Pedro On Sun, 13 Mar 2005 00:54:03 -0000, Nayra Quesada <[email protected]> wrote: > thanxs Pedro, but I had seen the manual and I still need some help. :-) > Could you give some idea about how to resolve my problem? Thanxsssssss > again!!!! :D > > -----Mensaje original----- > De: Pedro Vera [mailto:[email protected]] > Enviado el: domingo, 13 de marzo de 2005 0:39 > Para: Nayra Quesada > Asunto: Re: [SMARTY] modifiers functions > > > This is straight off the manual: > > Example 5-20. truncate > <?php > > $smarty = new Smarty; > $smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen > Years at Checkout Counter.'); > $smarty->display('index.tpl'); > > ?> > > where index.tpl is: > > {$articleTitle} > {$articleTitle|truncate} > {$articleTitle|truncate:30} > {$articleTitle|truncate:30:""} > {$articleTitle|truncate:30:"---"} > {$articleTitle|truncate:30:"":true} > {$articleTitle|truncate:30:"...":true} > > This will output: > > Two Sisters Reunite after Eighteen Years at Checkout Counter. > Two Sisters Reunite after Eighteen Years at Checkout Counter. > Two Sisters Reunite after... > Two Sisters Reunite after > Two Sisters Reunite after--- > Two Sisters Reunite after Eigh > Two Sisters Reunite after E... > > -- > Pedro Vera > http://veraperez.com > PGP/GPG Public Key: B21A55FA > > -- Pedro Vera http://veraperez.com PGP/GPG Public Key: B21A55FA