Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Variable doesnt work properly

 
Post new topic   Reply to topic    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
nikit0
Smarty Rookie


Joined: 26 Jan 2012
Posts: 5

PostPosted: Thu Jan 26, 2012 12:30 am    Post subject: Variable doesnt work properly Reply with quote

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


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

PostPosted: Thu Jan 26, 2012 3:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
nikit0
Smarty Rookie


Joined: 26 Jan 2012
Posts: 5

PostPosted: Thu Jan 26, 2012 4:43 pm    Post subject: Reply with quote

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
View user's profile Send private message
nikit0
Smarty Rookie


Joined: 26 Jan 2012
Posts: 5

PostPosted: Thu Jan 26, 2012 4:51 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    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