|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
pedrotester Smarty Regular
Joined: 06 Jun 2019 Posts: 40
|
Posted: Tue Jul 02, 2019 11:57 pm Post subject: truncate vs character_limit |
|
|
In which way using truncate from smarty is better than invoking character_limit from php? just being a curious noob |
|
Back to top |
|
carpii Smarty Rookie
Joined: 06 Sep 2008 Posts: 18
|
Posted: Wed Jul 03, 2019 12:25 am Post subject: |
|
|
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 |
|
bsmither Smarty Elite
Joined: 20 Dec 2011 Posts: 322 Location: West Coast
|
Posted: Wed Jul 03, 2019 5:36 am Post subject: |
|
|
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 |
|
pedrotester Smarty Regular
Joined: 06 Jun 2019 Posts: 40
|
Posted: Wed Jul 03, 2019 1:50 pm Post subject: |
|
|
My bad, I posted this very quickly, it was "character_limiter" from codeigniter.
And your answers answered my question, thank you |
|
Back to top |
|
|
|
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
|