View previous topic :: View next topic |
Author |
Message |
[hans] Smarty n00b
Joined: 12 Jan 2016 Posts: 2
|
Posted: Tue Jan 12, 2016 7:26 pm Post subject: change function of intval |
|
|
hi, i've this code:
{$var|intval}
But, I need modify the funcion of the tag "intval" for my app, is it possible? what file i need modify?
Thanks! |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Jan 12, 2016 8:55 pm Post subject: |
|
|
You should use appropriate modifier. Not intval. |
|
Back to top |
|
elpmis Smarty Elite
Joined: 07 Jun 2007 Posts: 321
|
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Tue Jan 12, 2016 10:44 pm Post subject: |
|
|
This is not the right place for jokes of such nature. |
|
Back to top |
|
[hans] Smarty n00b
Joined: 12 Jan 2016 Posts: 2
|
Posted: Wed Jan 13, 2016 8:29 am Post subject: |
|
|
Hi, thanks all
can i make this function? it is correct?
in /smarty/plugins/modifier.intval.php
function smarty_intval($var)
{
if ( isfloat($var) ) return $var;
else return intval($var);
} |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Jan 14, 2016 12:06 am Post subject: |
|
|
No, this is NOT correct.
You must use DIFFERENT modifier. NOT intval.
There's already a dozen of modifiers built into Smarty.
One of them should do the formatting you need. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jan 27, 2016 10:34 pm Post subject: |
|
|
AnrDaemon you are wrong. You can overload the PHP inval() function with a modifier pluging. Smarty does try to locate first a plugin before it tries a PHP function with same name. |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Thu Jan 28, 2016 1:03 pm Post subject: |
|
|
Yes, yes.
And
is perfectly valid preprocessor directive, too.
Please reconsider your reply. |
|
Back to top |
|
|