Sorting on a field now has a numeric sort option

In the past, all database fields were treated as alphanumeric. For most purposes, this works fine, even if you are storing numbers.

However, it is problematic when you are sorting by a field that has numbers. To get things to sort properly as numbers, you had to make sure that all numbers had the same number of digits, adding leading zeros as needed (001, 002, etc.)

Now you can specify when sorting on a field that you want it treated as a numeric field. The syntax is as follows:

<w:kb:item:each type="product" sort="price;number asc">

Note the ";number" after the field name; this triggers the numeric sorting behavior. As always, you should then add "asc" or "desc" to specify ascending or descending sort order.

In addition, when adding a custom field to a custom item type, there is a new option: "Number". By choosing this option, the field will be validated when information is entered, and only numeric content will be accepted.

Note that the sorting behavior is not automatic; you must also specify "fieldname;number" when sorting, even if the field type is set to Number.

Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.
Powered by Zendesk