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

Fatal Error with math in if Statement

 
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 -> Bugs
View previous topic :: View next topic  
Author Message
Nick
Smarty n00b


Joined: 11 May 2003
Posts: 2

PostPosted: Sun May 11, 2003 9:23 pm    Post subject: Fatal Error with math in if Statement Reply with quote

The following if-Statement worked in Smarty 2.3.0:

{ if $display != "" && $width > ( 2.5 * $height) }

but in Smarty 2.5.0 I got this fatal error:

Fatal error: Smarty: [in liquid/main.tpl line 55]: syntax error: unidentified token '2.5' (Smarty_Compiler.class.php, line 1228) in ..... Smarty-2.5.0/libs/Smarty_Compiler.class.php on line 1824


after changing the if-Statement to:

{ if $display != "" && $width > ( 2 * $height) }

no error occurs.
Back to top
View user's profile Send private message Visit poster's website
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Sun May 11, 2003 9:25 pm    Post subject: Reply with quote

That would probably have to do with Smarty's unability to do math operations but I could be wrong. Try
{ if $display != "" && $width > {math equation="2.5 * height" height=$height} }
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Sun May 11, 2003 11:36 pm    Post subject: Reply with quote

When you say it worked, what did it REALLY do? Did it evaluate the comparison properly? I don't think that it should ever have truly "worked" (even if it didn't throw an error) for the reason that Aztek gave.

Unfortunately, Aztek's solution won't work -- you can't embed a Smarty statement inside another Smarty statement. Alas.
Back to top
View user's profile Send private message
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Mon May 12, 2003 12:13 am    Post subject: Reply with quote

Yea your right I never tried it or really thought about it
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
AZTEK
Smarty Pro


Joined: 16 Apr 2003
Posts: 235
Location: Purdue University

PostPosted: Mon May 12, 2003 12:17 am    Post subject: Reply with quote

Before this turns into a why we urn for Smarty math support post. I think its probably Smarty thinking your trying to access an array key.
_________________
"Imagine a school with children that can read and write, but with teachers who cannot, and you have a metaphor of the Information Age in which we live." -Peter Cochrane
Back to top
View user's profile Send private message Visit poster's website
Nick
Smarty n00b


Joined: 11 May 2003
Posts: 2

PostPosted: Mon May 12, 2003 6:51 am    Post subject: Reply with quote

Back to top
View user's profile Send private message Visit poster's website
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 -> Bugs 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