Re: [SMARTY] modifiers functions
| From: | Werner | Date: | Sun, 13 Mar 2005 01:58:41 +0000 |
| Subject: | Re: [SMARTY] modifiers functions | ||
| References: | 1 2 3 4 5 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-12322@lists.php.net to get a copy of this message | ||
Hi Matt
Yes, that's the easy way, the php-way :-) I just got the impression that Nayra wanted to know how to do it the smarty-way, which made it quite interesting.
Matt Warden wrote:
http://php.net/str-pad On Sun, 13 Mar 2005 03:47:18 +0200, Werner <nospam@ubertech.co.za> wrote:That was quite an interesting question. Here is the "ready-to-use" version, assuming that your string is assigned to $str: <!-- Smarty Code Begins --> {assign var="strlen" value=$str|count_characters} {if ($strlen) >= 20} {$str|truncate:20:"..."} {else} {math equation="20-x" x=$strlen assign="padlength"} {$str}{section name="space" loop=$padlength} {/section} {/if} <!-- Smarty Code Ends -->