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

change function of intval

 
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
[hans]
Smarty n00b


Joined: 12 Jan 2016
Posts: 2

PostPosted: Tue Jan 12, 2016 7:26 pm    Post subject: change function of intval Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Jan 12, 2016 8:55 pm    Post subject: Reply with quote

You should use appropriate modifier. Not intval.
Back to top
View user's profile Send private message
elpmis
Smarty Elite


Joined: 07 Jun 2007
Posts: 321

PostPosted: Tue Jan 12, 2016 9:59 pm    Post subject: Reply with quote

intval is a PHP command which can be used as Smarty modifier

https://secure.php.net/manual/en/function.intval.php

So you have to modify the PHP core Very Happy.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Tue Jan 12, 2016 10:44 pm    Post subject: Reply with quote

elpmis wrote:

This is not the right place for jokes of such nature.
Back to top
View user's profile Send private message
[hans]
Smarty n00b


Joined: 12 Jan 2016
Posts: 2

PostPosted: Wed Jan 13, 2016 8:29 am    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jan 14, 2016 12:06 am    Post subject: Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Wed Jan 27, 2016 10:34 pm    Post subject: Reply with quote

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
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Jan 28, 2016 1:03 pm    Post subject: Reply with quote

Yes, yes.
And
Code:
#define TRUE FALSE

is perfectly valid preprocessor directive, too.
Please reconsider your reply.
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