Reputation: 1747
I have a sentece that works like a title, but is to big to be shown in the page. I can I set the variable to only show a bit of the sentence in symfony? Thanks.
Upvotes: 0
Views: 332
Reputation: 4506
Use the TextHelper. (use_helper('Text');
) It has some nice functions like truncate_text()
.
You can use it like this (in your View):
<?php use_helper('Text'); ?>
...
<?php echo truncate_text($text, 50); ?>
(The optional third parameter specifies which text you want to add when the text is being truncated (defaults to '...'). The optional boolean fourth parameter specifies wether you want to break on spaces explicitly. (and not somewhere in the middle of a word).
Upvotes: 2