Page 1 of 1

<If: Field Question>

PostPosted: Thu Apr 17, 2008 7:50 pm
by Sulley
Hey, I have a question. I know that if you enter a zero into a Field item that has the If tag attached, then it won't show up. Is there anyways to make it so it will show up?

I am doing a site for a soccer team and have the If tags on part of the score info, and in some games there will be zero goals for a team. Is there someway around this so that a zero does show up in an If tag?

Thanks.

PostPosted: Thu Apr 17, 2008 8:27 pm
by driv
I think you need to be looking at If/Else statements.

Something like...

Code: Select all
<If: Field: Score == 0>
 Something happens
 <If: Else>
Something Else happens
</If>


Can you post your existing code to take a look at?

PostPosted: Fri Apr 18, 2008 4:32 am
by Dale Ray
If you want to check to see if a value has been entered for a team's score do not use the mathematical comparison:
Code: Select all
<If: Field: Score == 0>

This checks to see if Score is zero.

Instead use a string comparison:
Code: Select all
<If: Field: Score ne "">

This checks to see if anything has been entered into the score field. Once you know a value has been entered you can check to see what the value is.

If you are allowing multiple users to enter info you will want to do further error checking.

You may want to use the CustomFields addon so that you can validate the input.

PostPosted: Fri Apr 18, 2008 3:46 pm
by Sulley
Hey Dale, thanks for your help...that did it, it now works perfectly.

Here's what I did:
Code: Select all
<If: Field: CustomField_StJohnsScore ne "111">


I just put a large number in there, which the score will never reach, and everything shows up as it should. Thanks for your help.

you can take a look at the progress if you want here. I am using coranto for the schedule, news, scores, and possibly the roster. Some things don't display correctly in IE, but everything looks and works as it should in Firefox. Still working on the IE bugs.

PostPosted: Fri Apr 18, 2008 4:21 pm
by Musicvid
Just a note of caution, something I'm sure you know if you work for a school:

You need signed release statements from the parents of all players named, pictured, quoted, or described on your site prior to publication. Just one objection or misuse of information published on your site can sink you.

PostPosted: Sat Apr 19, 2008 7:09 pm
by driv
Dale Ray wrote:If you want to check to see if a value has been entered for a team's score do not use the mathematical comparison


My bad Dale :( --- I just wanted to suggest the possibility of the Else statement.

PostPosted: Mon Apr 21, 2008 4:05 pm
by Dale Ray
driv wrote:
Dale Ray wrote:If you want to check to see if a value has been entered for a team's score do not use the mathematical comparison


My bad Dale :( --- I just wanted to suggest the possibility of the Else statement.


Using If/Else is a requirement anytime you get into more complicated scenarios.

Perl treats your data (stuff stored as the value of a variable) as whatever type you treat it as. So a variable with a value of 1 will be treated as numeric if you use numeric comparisons (==, !=) and as a string if you use string comparisons (ne, eq). This can be useful, as in the example above where you want to see if anything is stored in a variable and don't have sophisticated data checking in place. If there is nothing there (no value assigned) you can then skip the checks to see if the data is the proper type.