We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30023
    • 172 Posts
    I am using Ditto Filtering on a couple of number TVs. Everything works fine as long as the TV values are numeric - however as far as I can see setting an ’Input Type’ of number does not actually force the user to use numeric values.

    So filtering when the user has entered 2500 into a TV is fine, as a numeric comparision is done if the strings are numeric. However if a user types in 2,500 Ditto now does a string comparison - and the filters do not work as intended.

    Is there a way to force Ditto to do a numeric comparison? Alternatively, is there an existing built in method to force the manager to only accept numeric values for Number inputs?

    Lastly - is it just me or are the Ditto comparsion modes 5 and 6 the wrong way round here http://ditto.modxcms.com/tutorials/basic_filtering.html ?

    I’m using MODx 1.0.1 and Ditto 2.1.0.

    -- Tim.
      • 30023
      • 172 Posts

      I’m reckoning this is a bug, probably not with Ditto but in the way template variables are stored i.e. Number TVs ought to be numbers.

      As far as I can see, if number TVs were indeed numbers, then the code in Ditto’s filter.class.inc.php would do a numeric comparison.

      I think I will write a plugin to ’sanitise’ the entered Number value and copy the result to another TV. This keeps the original ’number’ as entered intact e.g. "2,500" for display. Elsewhere however I can have a TV that is automatically filled with 2500 as a ’proper’ number for comparison purposes.

      -- Tim.