|
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 |
nikit0 Smarty Rookie
Joined: 26 Jan 2012 Posts: 5
|
Posted: Thu Jan 26, 2012 12:30 am Post subject: Variable doesnt work properly |
|
|
Hello everybody and thank you all for the support,
I have a strange situation, variable $listing.Powerr is already defined during the input form car form, in this case is 415.
On the view listing page i output it [[$listing.Power]] and it works...
when i make an operation to get the Kw from HP like i said 415 for this user car. (415/1.36) below the code
Code: | {if $listing.Powerr != ''}
<tr><td>
[[Power1]]:</td>
<td><b>{math equation="x / y" x=$listing.Powerr y=1.36 format="%.0f"}([[$listing.Powerr]]CV)</b>
</td></tr>{/if} |
there's no output from that operation..... but the [[$listing.Powerr]] output me the value 415.... i really dont understand why doesnt calculate properly..... if u put manually 415 it works....
Please help me thank you all |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Jan 26, 2012 3:53 pm Post subject: |
|
|
Looks like you have redefined the Smarty delimiters to '[[' and ']]'.
Then you must use these also for the 'if' and 'math' tags. |
|
Back to top |
|
nikit0 Smarty Rookie
Joined: 26 Jan 2012 Posts: 5
|
Posted: Thu Jan 26, 2012 4:43 pm Post subject: |
|
|
i use [[]] just to display the value infacts if i do:
Code: | {if $listing.Powerr == 415} | it works correctly
even if i do Code: | {$listing.Powerr/2} | the output is 0.5 like the value of $listing.Powerr is 1... its so strange i dont know where im wrong[/code] |
|
Back to top |
|
nikit0 Smarty Rookie
Joined: 26 Jan 2012 Posts: 5
|
Posted: Thu Jan 26, 2012 4:51 pm Post subject: |
|
|
Solved in this way:
Code: | {if $listing.Powerr != ''}
<tr><td>
[[Power1]]:</td>
{assign var=x value=$listing.Powerr}
{assign var=y value=1.36}
<td><b>{math equation="$x / $y" format="%.0f"}Kw([[$listing.Powerr]]CV)</b>
</td></tr>{/if} |
now works properly, thank you for the help by the way |
|
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
|