<If: Field Question>

Is Coranto not working properly for you? Here's where to ask for support help; for best results, follow these steps:
  • - Check your core/addon documentation for possible solutions
  • - Search these forums for similar problems that have already been solved
  • - If you're still stumped, check out THIS TOPIC, and post your question in this forum!!

Moderators: Spunkmeyer, Dale Ray, SrNupsen, Bluetooth, Jackanape

<If: Field Question>

Postby Sulley » Thu Apr 17, 2008 7:50 pm

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.
Sulley
 
Posts: 6
Joined: Thu Apr 10, 2008 2:24 pm

Postby driv » Thu Apr 17, 2008 8:27 pm

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?
driv
 
Posts: 69
Joined: Wed May 05, 2004 10:30 am

Postby Dale Ray » Fri Apr 18, 2008 4:32 am

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.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana

Postby Sulley » Fri Apr 18, 2008 3:46 pm

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.
Sulley
 
Posts: 6
Joined: Thu Apr 10, 2008 2:24 pm

Postby Musicvid » Fri Apr 18, 2008 4:21 pm

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.
Musicvid
 
Posts: 138
Joined: Wed Jan 17, 2007 1:05 am
Location: Western America

Postby driv » Sat Apr 19, 2008 7:09 pm

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.
driv
 
Posts: 69
Joined: Wed May 05, 2004 10:30 am

Postby Dale Ray » Mon Apr 21, 2008 4:05 pm

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.
Dale Ray
User avatar
Dale Ray
 
Posts: 1001
Joined: Sun Jan 19, 2003 6:02 pm
Location: NW Indiana


Return to Troubleshooting

Who is online

Users browsing this forum: No registered users and 2 guests

cron