ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Check for Empty, but not Zero's

August 24, 2011 5:40pm

Subscribe [3]
  • #1 / Aug 24, 2011 5:40pm

    blendimc

    150 posts

    I have a field that people enter scores into,  and sometimes the score is zero, and sometimes its blank. I want to show the score if it is 0, but not if it is blank. How would I be able to do this since {if field} returns false if 0 is entered in?

  • #2 / Aug 24, 2011 7:37pm

    Mark Bowen

    12637 posts

    Hiya,

    Something like this should do what you need if I’m reading your post correctly :

    {if score_field != ""}
    {score_field}
    {/if}

    You’ll want to change score_field above for whatever the name of your custom field is but that should hopefully get you what you want. Basically the conditional above is just checking for something to be in the field. If nothing has been typed into the field then nothing will be output. If there is something in the field then it will be output which I believe is what you’re after here.

    Best wishes,

    Mark

  • #3 / Aug 25, 2011 2:29am

    John Henry Donovan

    12339 posts

    blendimc,

    Did Mark’s answer help?

  • #4 / Sep 02, 2011 9:30pm

    Mark Bowen

    12637 posts

    Hi blendimc,

    Just wanted to see if that worked for you?

    Cheers,

    Mark

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases