nested if: else statements help

Discuss news styles, css code, and other Coranto customizations in here...the possibilities are endless, so have at it!

Moderator: Spunkmeyer

nested if: else statements help

Postby PPNSteve » Mon Jul 04, 2005 9:24 pm

OK i'm not a perl expert here so i need a little help with nesting some if else statements for one of the styles:

heres what we have now:
Code: Select all
<If: Field: TextField: CustomField_ESRB eq "E">
  <img src="ratings/e.gif" />
 <If: Else>
  <img src="ratings/rp.gif" />
 </If>
 
 <If: Field: TextField: CustomField_ESRB eq "EC">
  <img src="ratings/e10.gif" />
 <If: Else>
  <img src="ratings/rp.gif" />
 </If>
 
 <If: Field: TextField: CustomField_ESRB eq "T">
  <img src="ratings/t.gif" />
 <If: Else>
  <img src="ratings/rp.gif" />
 </If>
 
 <If: Field: TextField: CustomField_ESRB eq "M">
  <img src="ratings/m.gif" />
 <If: Else>
  <img src="ratings/rp.gif" />
 </If>
 
 <If: Field: TextField: CustomField_ESRB eq "A">
  <img src="ratings/a.gif" />
 <If: Else>
  <img src="ratings/rp.gif" />
 </If>
 
 <If: Field: TextField: CustomField_ESRB eq "RP">
  <img src="ratings/rp.gif" />
 </If>

And this is the error message we get when we submit the style:
Error: That style is invalid and has a syntax error. Check, in particular, that all ifs are properly matched and ended. Perl reported the following error, which may or may not be helpful: syntax error at (eval 10) line 29, near "} else" (Might be a runaway multi-line ~~ string starting on line 20)


Can anyone help us out with this???

and yes, I tried it as:
Code: Select all
<If: Field: TextField: CustomField_ESRB eq "E">
  <img src="ratings/e.gif" />
 <If: Else>
 <If: Field: TextField: CustomField_ESRB eq "EC">
  <img src="ratings/e10.gif" />
 <If: Else>
 <If: Field: TextField: CustomField_ESRB eq "T">
  <img src="ratings/t.gif" />
 <If: Else>
 <If: Field: TextField: CustomField_ESRB eq "M">
  <img src="ratings/m.gif" />
 <If: Else>
 <If: Field: TextField: CustomField_ESRB eq "A">
  <img src="ratings/a.gif" />
 <If: Else>
 <If: Field: TextField: CustomField_ESRB eq "RP">
  <img src="ratings/rp.gif" />
 <If: Else>   
  <img src="ratings/rp.gif" />
 </If>


with the error message saying:
Error: That style is invalid and has a syntax error. Check, in particular, that all ifs are properly matched and ended. Perl reported the following error, which may or may not be helpful: syntax error at (eval 10) line 29, near "} else" (Might be a runaway multi-line ~~ string starting on line 20)


HELP!!!
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby Psykosys » Mon Jul 04, 2005 11:30 pm

The best solution here would be to name the images in uppercase and then just have:
Code: Select all
<If: Field: CustomField_ESRB>
<img src="ratings/<Field: CustomField_ESRB>.gif" />
<If: Else><img src="ratings/rp.gif" /></If>
Way more efficient and should work, unlike the current code (which could just be missing a few closing </If> tags because of all the nesting...)
Psykosys
 
Posts: 252
Joined: Tue Apr 15, 2003 10:37 pm
Location: Ithaca, NY

Postby PPNSteve » Mon Jul 04, 2005 11:48 pm

Psykosys wrote:The best solution here would be to name the images in uppercase and then just have:
Code: Select all
<If: Field: CustomField_ESRB>
<img src="ratings/<Field: CustomField_ESRB>.gif" />
<If: Else><img src="ratings/rp.gif" /></If>
Way more efficient and should work, unlike the current code (which could just be missing a few closing </If> tags because of all the nesting...)


duh i'm so dumb at times.. I don't know why i didn't think of that..

great idea!!
PPNSteve
 
Posts: 9
Joined: Tue Feb 20, 2007 12:57 am

Postby LoneOwl » Tue Jul 05, 2005 1:55 am

The original problem is that there is no <If: Field: TextField: Var> tag, but there is <If: Field: Var>.
User avatar
LoneOwl
 
Posts: 1465
Joined: Sun Mar 10, 2002 2:57 am
Location: That one place, you know?


Return to Customization

Who is online

Users browsing this forum: No registered users and 4 guests

cron