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.

Number Type Problem

April 02, 2011 9:46am

Subscribe [4]
  • #1 / Apr 02, 2011 9:46am

    Liam Crean

    121 posts

    Hello. I need to sort a page of entries by price (2 decimals).

    Only problem is EE sees them as alphanumeric not integers.

    So what should order like:

    1.99
    2.99
    9.99
    19.99
    29.99

    Orders like:

    1.99
    19.99
    2.99
    29.99
    9.99

    I’ve tried changing the table containing that data in MySQL to ‘int’ but that doesnt work. Also tried ‘decimal’ - no avail. Is there a native EE parameter or some PHP maybe that will help?

    Thanks, Liam

  • #2 / Apr 04, 2011 3:30am

    John Henry Donovan

    12339 posts

    Liam,

    For each custom field you have the option of changing it to an Integer or Number in it’s preferences

    Does that help?

  • #3 / Apr 04, 2011 4:47am

    Liam Crean

    121 posts

    Hi John

    The only place I can think to find that option is in the “Default Text Formatting for This Field” part of the fields page.

    Couldn’t see integer/number in those options. (V1.6.9) Unless I’m looking in the wrong place?

    Ta.

  • #4 / Apr 04, 2011 8:08am

    Mark Bowen

    12637 posts

    Nope Number / Integer doesn’t exist for the 1.x version of ExpressionEngine, only from 2.x upwards I’m afraid.

    The only ways I know of fixing that in 1.x is to either use padding in front of the numbers like 000010, 000011 etc… or you would need to alter the database column slightly to change it from text to INT.

    Best wishes,

    Mark

  • #5 / Apr 04, 2011 10:47am

    Liam Crean

    121 posts

    to either use padding in front of the numbers like 000010, 000011

    Can’t use this method - interferes with outputs in cart/taxes/etc.

    Or you would need to alter the database column slightly to change it from text to INT.

    As I said in my first post - I tried this - it doesn’t work with 2 decimal places.

    Hmn…

  • #6 / Apr 04, 2011 1:22pm

    Mark Bowen

    12637 posts

    Sorry I had meant to say set it to Float with a precision of 2 to get what you need.

    Best wishes,

    Mark

  • #7 / Apr 04, 2011 2:20pm

    Liam Crean

    121 posts

    Perfect thanks Mark - works a charm - ideal for prices/carts/etc.

  • #8 / Apr 06, 2011 9:21am

    Sue Crocker

    26054 posts

    Thanks for the assist, Mark.

    Liam - Feel free to start a new thread if you have any more questions.

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

ExpressionEngine News!

#eecms, #events, #releases