Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

truncate vs character_limit

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
pedrotester
Smarty Regular


Joined: 06 Jun 2019
Posts: 40

PostPosted: Tue Jul 02, 2019 11:57 pm    Post subject: truncate vs character_limit Reply with quote

In which way using truncate from smarty is better than invoking character_limit from php? just being a curious noob
Back to top
View user's profile Send private message
carpii
Smarty Rookie


Joined: 06 Sep 2008
Posts: 18

PostPosted: Wed Jul 03, 2019 12:25 am    Post subject: Reply with quote

What do you mean by invoking character_limit?

There is no PHP function or ini setting called this.
Maybe you are using a framework which provides it, but even so I can't find any reference to it.

Anyway, if you use PHP to truncate the string, then Smarty cannot render anything longer than what PHP assigned to it.

If you are truncating it just for display purposes, then it is better to do it in your Smarty template
Back to top
View user's profile Send private message
bsmither
Smarty Elite


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

PostPosted: Wed Jul 03, 2019 5:36 am    Post subject: Reply with quote

I concur.

Knowing from the template's design how much screen real-estate is available, chopping a string could be considered a display task.

Since the choice of template designs are programmatically determined, one template design may have more or less screen real-estate than any other template design. So, it is a less than an ideal solution to have PHP core code perform this task on a one size fits all basis.
Back to top
View user's profile Send private message
pedrotester
Smarty Regular


Joined: 06 Jun 2019
Posts: 40

PostPosted: Wed Jul 03, 2019 1:50 pm    Post subject: Reply with quote

My bad, I posted this very quickly, it was "character_limiter" from codeigniter.

And your answers answered my question, thank you Razz
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    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