check smarty var is integer in template

Discussion corner for Developers of Serendipity.
Post Reply
User avatar
Timbalu
Regular
Posts: 4598
Joined: Sun May 02, 2004 3:04 pm

check smarty var is integer in template

Post by Timbalu » Tue Jan 27, 2015 4:04 pm

Its a real pity we do not allow is_int($foo) or is_numeric($foo) by security as default for smarty.
So you cannot check for a numeric or have to create & use a modifier {$oo|intval}.

I almost gave up on this, but then I remembered casting to be allowed, so

Code: Select all

{if (int)$foo} will do {/if}
;-)
Regards,
Ian

Serendipity Styx Edition and additional_plugins @ https://ophian.github.io/ @ https://github.com/ophian

Post Reply