Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Problems with the truncate modifier

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
n2fole00
Smarty Rookie


Joined: 09 Jun 2020
Posts: 6

PostPosted: Wed Jun 10, 2020 10:34 am    Post subject: Problems with the truncate modifier Reply with quote

Hi, I have the following I was trying out...
Code:

{$controller|truncate:3} this just returns ...
{substr($controller,0,3)}... this works as expected (myc...)
{$title|substr($controller,0,3)}... this breaks the page

Note: $controller is a string like "MyControllerName".
Ideally, I would like to get the first line working, but it doesn't work as expected. Any ideas?

Thanks.
Back to top
View user's profile Send private message
bsmither
Smarty Elite


Joined: 20 Dec 2011
Posts: 270
Location: West Coast

PostPosted: Wed Jun 10, 2020 7:35 pm    Post subject: Reply with quote

The docs mention:
"[The default trailing string, '...'] length is included in the truncation length setting."

So, maybe
Code:
{$controller|truncate:6}
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1646

PostPosted: Thu Jun 11, 2020 4:43 pm    Post subject: Reply with quote

bsmither wrote:
The docs mention:
"[The default trailing string, '...'] length is included in the truncation length setting."

So, maybe
Code:
{$controller|truncate:6}


Or
Code:
{$controller|truncate:4:\u{2026}}
Back to top
View user's profile Send private message
n2fole00
Smarty Rookie


Joined: 09 Jun 2020
Posts: 6

PostPosted: Thu Jun 11, 2020 7:28 pm    Post subject: Reply with quote

Yes, you're right! Darn my poor comprehension skills.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP