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.

Conditional comparing numbers not working

November 09, 2012 11:30am

Subscribe [3]
  • #1 / Nov 09, 2012 11:30am

    Rob Allen

    3108 posts

    EE2.3.1

    I have two channel entries tags, both identical except each variation needs to look up a number that’s stored in a custom field, and output less than, or more than totals, called by a simple conditional.

    Field data_distance stores a number, eg 12.05947 or 2936.939, and there are entries that can be filtered (I output “all” data elsewhere so I know it’s there!).

    Here’s my basic code:

    {exp:channel:entries channel="data" search:data_type="Redeem" dynamic="no"}
    {if data_distance <= '50'}
    {if count == total_results}Total results {total_results}{/if}
    {/if}
    {/exp:channel:entries}
    
    {exp:channel:entries channel="data" search:data_type="Redeem" dynamic="no"}
    {if data_distance > '50'}
    {if count == total_results}Total results {total_results}{/if}
    {/if}
    {/exp:channel:entries}

    The first tag has 1 out of 4 available entries to display, but total_results is blank (no output at all).

    The second tag has 3 out of 4 available entries to display, but total_results outputs “4”, not “3” as it should do.

    Stumped!

    Any ideas?

     

  • #2 / Nov 09, 2012 2:42pm

    e-man

    1816 posts

    What happens if you use {if data_distance <= 50} sans single quotes?
    Scratch that :I

    The search parameter will only work with fields of the type “Text Input”, “Textarea”, and “Drop-down Lists”.
    http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#search-field-name

  • #3 / Nov 10, 2012 5:21am

    Rob Allen

    3108 posts

    What happens if you use {if data_distance <= 50} sans single quotes?
    Scratch that :I

    The search parameter will only work with fields of the type “Text Input”, “Textarea”, and “Drop-down Lists”.
    http://ellislab.com/expressionengine/user-guide/modules/channel/channel_entries.html#search-field-name

    Hi e-man

    Yes have tried all sort sof variations 😊

    I’m not strictly using the search parameter here…

  • #4 / Nov 10, 2012 8:43am

    e-man

    1816 posts

    Do any of your entries have a status of some kind? Are they all ‘open’?

  • #5 / Nov 12, 2012 5:04am

    Rob Allen

    3108 posts

    Hey e-man.

    Just open and closed statuses, so nothing special!

    What is strange if I output

    {if data_distance <= '50'}
    Distance is below 50, 
    {if count == total_results}Total results {total_results}{/if}
    {/if}

    ...it outputs Distance is below 50, Distance is below 50, Distance is below 50, Distance is below 50, Distance is below 50,  etc - so it is seeing the data, just ignoring count/total results.

  • #6 / Nov 12, 2012 9:59am

    glenndavisgroup

    436 posts

    What if you try:

    {exp:channel:entries channel="data" search:data_type="Redeem" dynamic="no"}
    {if data_distance <= '50' && count == total_results}
    Total results {total_results}
    {/if}
    {/exp:channel:entries}
    
    {exp:channel:entries channel="data" search:data_type="Redeem" dynamic="no"}
    {if data_distance > '50' && count == total_results}
    Total results {total_results}
    {/if}
    {/exp:channel:entries}

    Mike

  • #7 / Nov 12, 2012 10:10am

    Rob Allen

    3108 posts

    Thanks for the idea Mike, but still no output with that.

  • #8 / Nov 12, 2012 11:00am

    e-man

    1816 posts

    This is too weird… what happens when you output just:

    {exp:channel:entries channel="data" search:data_type="Redeem" dynamic="no"}
    
    {count} - {total_results}
    
    
    {/exp:channel:entries}

    ?

  • #9 / Nov 12, 2012 11:06am

    Rob Allen

    3108 posts

    That just outputs the total as you’d expect 1-28, 2-28 3-28 etc.

    By rights it should just work shouldn’t it!

  • #10 / Nov 12, 2012 12:36pm

    Shane Eckert

    7174 posts

    Hi Rob,

    Thank you for posting your question.

    What do you see when you enable the Template Profiler?

    I am wondering if the value is being picked up in time or if it just loops through the text.

    Can you enable that and see of you can spot the break down as the parser works through your code?

    Thank you,

  • #11 / Nov 12, 2012 12:51pm

    Rob Allen

    3108 posts

    Hi Shane

    Not sure exactly what to look for:

    [MOD EDIT] removed content

  • #12 / Nov 12, 2012 12:51pm

    Rob Allen

    3108 posts

    [MOD EDIT] removed content

  • #13 / Nov 13, 2012 5:10pm

    Shane Eckert

    7174 posts

    Hey there Rob,

    I think this might be quicker if I get in a take a look.

    Please be on the lookout for an email from EllisLab.

    Thanks,

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

ExpressionEngine News!

#eecms, #events, #releases