|
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 |
michelefaccini Smarty n00b
Joined: 15 Jan 2019 Posts: 3 Location: Italy
|
Posted: Wed Jan 16, 2019 9:04 am Post subject: Newbie ask for help |
|
|
Hi all, I had the following with Smarty 2
Code: | $smarty->register_function('smarty_fewchars', 'smarty_fewchars'); |
I tried the following for Smarty 3 but it doesn't run :
Code: | $smarty->register->templateFunction('smarty_fewchars', 'smarty_fewchars'); |
Code: | function fewchars($s, $lenght)
{
$str_to_count = html_entity_decode($s);
if (mb_strlen($str_to_count, "UTF-8" ) <= $lenght)
{
return $s;
}
$s2 = mb_substr($str_to_count, 0, $lenght - 3, "UTF-8")."...";
return $s2;
}
function smarty_fewchars($params, &$smarty)
{
if (empty($params['s']))
return '';
if (empty($params['length']))
$params['length'] = 255;
return fewchars($params['s'], $params['length']);
} |
Please help me..... |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
|
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
|