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

Problem w<ith {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 -> General
View previous topic :: View next topic  
Author Message
metheorn
Smarty Rookie


Joined: 22 Aug 2003
Posts: 14

PostPosted: Fri Aug 22, 2003 1:01 pm    Post subject: Problem w<ith {if} statement Reply with quote

Hello,

It's seems that i can't use variable from an array in a if statement

Code:

{section name=i loop=$agences}
{if {$agence[i].GrpNom} == "XXX" }



This code don't work. It returns always true.

Someone has an idea ?
Back to top
View user's profile Send private message
mocean
Smarty Rookie


Joined: 21 May 2003
Posts: 30
Location: The Netherlands

PostPosted: Fri Aug 22, 2003 1:24 pm    Post subject: Re: Problem w<ith {if} statement Reply with quote

metheorn wrote:
Hello,

It's seems that i can't use variable from an array in a if statement

Code:

{section name=i loop=$agences}
{if {$agence[i].GrpNom} == "XXX" }



This code don't work. It returns always true.

Someone has an idea ?

Have you tried
Code:

{section name=i loop=$agences}
{if agence[i].GrpNom == "XXX" }

?
_________________
Visit My Smarty Enabled Website (Dutch Only) at www.habiforum.nl
and read how it works.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
metheorn
Smarty Rookie


Joined: 22 Aug 2003
Posts: 14

PostPosted: Fri Aug 22, 2003 1:32 pm    Post subject: Reply with quote

Here is the result with {if agence[i].GrpNom == "XXX" }

Code:
syntax error: unidentified token '[i].GrpNom' (Smarty_Compiler.class.php, line 1228)


With

Code:
{section name=i loop=$agences}
{if {$agence[i].GrpNom} == "FRANTOUR" }


The source page returns

Code:
== "FRANTOUR" }
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Fri Aug 22, 2003 1:49 pm    Post subject: Reply with quote

mocean did a small typo: Do not forget the "$" at the beginning of your variable! Wink

Therefore it should look like this:

Code:
{section name=i loop=$agences}
{if $agence[i].GrpNom == "XXX" }
Back to top
View user's profile Send private message
metheorn
Smarty Rookie


Joined: 22 Aug 2003
Posts: 14

PostPosted: Fri Aug 22, 2003 2:18 pm    Post subject: Reply with quote

Cela ne fonctionne toujours pas.

Cette fois ci, le résultat renvoie toujours FALSE ...
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Fri Aug 22, 2003 2:30 pm    Post subject: Reply with quote

$agences != $agence
Back to top
View user's profile Send private message Send e-mail Visit poster's website
metheorn
Smarty Rookie


Joined: 22 Aug 2003
Posts: 14

PostPosted: Fri Aug 22, 2003 2:37 pm    Post subject: Reply with quote

Embarassed Embarassed Embarassed

Arrrrhhhh......

What a mistake

thanks a lot, it's work
Back to top
View user's profile Send private message
andre
Smarty Pro


Joined: 23 Apr 2003
Posts: 164
Location: Karlsruhe, Germany

PostPosted: Mon Aug 25, 2003 6:23 am    Post subject: Reply with quote

Very Happy Very Happy Sorry Very Happy Very Happy
Back to top
View user's profile Send private message
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 -> 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