Update SortByField.php - #8
Conversation
|
And how do you know that all fields everyone is going to use, on all sites they're using this plugin on are integers? In fact, the example I give in the README is a date field which is not an integer. This is the problem with custom fields at the moment. They lack a method which would return the correct database expression to cast them into scalars for comparison, searching, etc. Lacking that, we can only assume they are stored as a JSON-encoded string which is sometimes not the case. You found one such case. There are other fields which store JSON objects or arrays. I cannot think of a good way you could deal with those fields. |
|
i came across this - maybe it will help others with the same problem |
|
If you have some ideas about how an interface to select the cast (and subelement if object or array) I'd like to hear it. I can't promise it can be implemented, but it's better than me drawing a blank on how to handle those cases. |
cast the value as SIGNED so that it sorts numerically
This is necessary because Joomla's custom fields are stored as strings, so a numeric field would sort alphabetically
Before this PR
1
11
111
2
3333
4
After this PR
1
2
4
11
111
3333