EllisLab text mark
Advanced Search
     
cant get if statement work for own module
Posted: 06 May 2009 12:17 PM   [ Ignore ]
Joined: 2008-01-28
54 posts

We’ve making a module for a marketplace where users can sell their items with images. Now we want to check or a advertisment has a image, but the if statement won’t work. The value of the variable does work, we can see the value.

{img1} 

will output the value. But this

{if img1 == ""}
  
empty
{if:else}
  
if not empty
{/if} 

always output empty, even when img1 is nog empty.

What are we doing wrong?

 
Posted: 06 May 2009 12:21 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Avatar
Joined: 2004-05-15
29075 posts

Aren’t you doing it exactly the wrong way around? if .. == “” means if ... empty, not “if not empty”.

 
Posted: 06 May 2009 03:57 PM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Joined: 2008-01-28
54 posts
Ingmar Greil - 06 May 2009 04:21 PM

Aren’t you doing it exactly the wrong way around? if .. == “” means if ... empty, not “if not empty”.

:D you’re right, but thats not the problem, it still doesnt work .. its always empty ..

 
Posted: 08 May 2009 10:07 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Avatar
Joined: 2008-01-07
2482 posts

Gert,

Are you calling prep_conditionals in your module?

 Signature 
 
Posted: 08 May 2009 10:27 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2006-04-15
12649 posts

Beat me to it wink

More information on Conditionals and using them in your own plugins and modules is here though.

 Signature 

Shopping Cart Plugin | Full List Of Add-Ons | About Me
——————————————————————————————
2.x Bug Tracker | Upgrade Errors