Subversion-Projekte lars-tiefland.laravel_shop

Revision

Zur aktuellen Revision | Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
truncate {#language.modifier.truncate}
2
========
3
 
4
This truncates a variable to a character length, the default is 80. As
5
an optional second parameter, you can specify a string of text to
6
display at the end if the variable was truncated. The characters in the
7
string are included with the original truncation length. By default,
8
`truncate` will attempt to cut off at a word boundary. If you want to
9
cut off at the exact character length, pass the optional third parameter
10
of TRUE.
11
 
12
   Parameter Position    Type     Required   Default  Description
13
  -------------------- --------- ---------- --------- ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
14
           1            integer      No        80     This determines how many characters to truncate to.
15
           2            string       No       \...    This is a text string that replaces the truncated text. Its length is included in the truncation length setting.
16
           3            boolean      No       FALSE   This determines whether or not to truncate at a word boundary with FALSE, or at the exact character with TRUE.
17
           4            boolean      No       FALSE   This determines whether the truncation happens at the end of the string with FALSE, or in the middle of the string with TRUE. Note that if this setting is TRUE, then word boundaries are ignored.
18
 
19
 
20
    <?php
21
    $smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
22
    ?>
23
 
24
 
25
 
26
where template is:
27
 
28
 
29
    {$articleTitle}
30
    {$articleTitle|truncate}
31
    {$articleTitle|truncate:30}
32
    {$articleTitle|truncate:30:""}
33
    {$articleTitle|truncate:30:"---"}
34
    {$articleTitle|truncate:30:"":true}
35
    {$articleTitle|truncate:30:"...":true}
36
    {$articleTitle|truncate:30:'..':true:true}
37
 
38
 
39
 
40
This will output:
41
 
42
 
43
    Two Sisters Reunite after Eighteen Years at Checkout Counter.
44
    Two Sisters Reunite after Eighteen Years at Checkout Counter.
45
    Two Sisters Reunite after...
46
    Two Sisters Reunite after
47
    Two Sisters Reunite after---
48
    Two Sisters Reunite after Eigh
49
    Two Sisters Reunite after E...
50
    Two Sisters Re..ckout Counter.
51
 
52