|
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 |
Nick Smarty n00b
Joined: 11 May 2003 Posts: 2
|
Posted: Sun May 11, 2003 9:23 pm Post subject: Fatal Error with math in if Statement |
|
|
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 |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Sun May 11, 2003 9:25 pm Post subject: |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Sun May 11, 2003 11:36 pm Post subject: |
|
|
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 |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Mon May 12, 2003 12:13 am Post subject: |
|
|
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 |
|
AZTEK Smarty Pro
Joined: 16 Apr 2003 Posts: 235 Location: Purdue University
|
Posted: Mon May 12, 2003 12:17 am Post subject: |
|
|
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 |
|
Nick Smarty n00b
Joined: 11 May 2003 Posts: 2
|
Posted: Mon May 12, 2003 6:51 am Post subject: |
|
|
|
|
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
|