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.

Urgent - Can't get EE to understand a negative number

February 14, 2011 1:22pm

Subscribe [1]
  • #1 / Feb 14, 2011 1:22pm

    John St-Amand

    865 posts

    Hi there - Is there a proper way to get EE to recognize negative values in a conditional?  I have an EE1 site with a weblog that includes an inventory field.  Occasionally the inventory field contains a negative value (coming from my client - believe it means one has been ordered but is not in stock and therefore must be ordered).  So in our product display templates, i have a conditional:

    {if inventory >> "0"}show the add to cart button{if:else}show out of stock message{/if}

    It works until such time that an entry includes a negative value in the inventory field.  Then, it still shows the add to cart button since it would appear EE conditionals are ignoring the negative.  I even tried a test is a blank template:

    {if "-1" >> "0"}wrong{if:else}right{/if}

    When i render it, i get “wrong” - so EE is definitely not recognizing that a negative value is NOT greater than zero.  What can I do about this?

  • #2 / Feb 14, 2011 4:18pm

    Ingmar

    29245 posts

    What version and build of EE are you using? That said, what is “>>” supposed to signify? It’s not a supported operator, to the best of my knowledge.

  • #3 / Feb 14, 2011 4:38pm

    John St-Amand

    865 posts

    Ah, so that’s the issue!  For some reason i thought you had to double up on > and < symbols like you do with =.  My bad.  I have changed it and it works fine now!

  • #4 / Feb 14, 2011 4:47pm

    Ingmar

    29245 posts

    Glad to see it was an easy one 😊 Please post again as needed.

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

ExpressionEngine News!

#eecms, #events, #releases