Caution: This documentation is for eZ Publish legacy, from version 3.x to 5.x.
For 5.x documentation covering Platform see eZ Documentation Center, for difference between legacy and Platform see 5.x Architecture overview.



Returns a shortened version of the input string.


input|shorten( [ length [, sequence [, trim_type ] ] ] )


length integer The desired length of the returned string. No.
sequence string Custom trailing/end-sequence. No.
trim_type string Controls the type of trimming: "right" (default) or "middle". No.


A shortened version of the input string.


This operator shortens the input string to "length" characters and adds a trailing sequence. Please note that the "length" parameter also includes the length of the trailing sequence. If the input string is shorter than "length", it will not be shortened. The default length is 80, the default trailing sequence is three dots: "...". The third parameter controls the type of trimming, it can be set to either "right" (default) or "middle".


Example 1

{'Led Zeppelin rocks!'|shorten( 15 )}

The following output will be produced: "Led Zeppelin...".

Example 2

{"eZ Systems"|shorten( 7, '...' , 'middle' )}

The following output will be produced: "".

Balazs Halasy (05/02/2004 10:59 am)

Svitlana Shatokhina (06/04/2006 1:46 pm)


There are no comments.