WebsiteBaker Support (2.12.x) > Modules
ONEFORALL - Group sorting bug
(1/1)
CodeALot:
If you use field type GROUP in OneForAll and SHOW GROUP HEADERS on, SORT BY GROUP on, the sorting goes wrong once you use more than 10 groups.
Sorting is done like:
1
10
11
2
3
4
5 --- etc.
Does anyone have a brilliant idea how to solve this?
dbs:
Hi, try this. Find in view_overview.php the block.
--- Code: ---// If a group field is defined order by group and position
--- End code ---
Last line of this block is
--- Code: --- .'ORDER BY `f`.`value` '.$group_order.', `i`.`position` '.$position_order.$limit_sql;
--- End code ---
Change it to
--- Code: --- .'ORDER BY LENGTH(`f`.`value`), `f`.`value` '.$group_order.', `i`.`position` '.$position_order.$limit_sql;
--- End code ---
Only this is added: LENGTH(`f`.`value`),
Hope it helps.
CodeALot:
You're the best. That solved it. MANY thanks!
DarkViper:
If it is certain that 'f.value' contains a number (integer), it is easier to evaluate this value in the sorting as a number.
This can be achieved with the SQL function CAST(expression AS datatype)'.
--- Code: --- .'ORDER BY CAST(`f`.`value` AS UNSIGNED) '.$group_order.', `i`.`position` '.$position_order.$limit_sql;
--- End code ---
see:
https://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_cast (function cast and description of types in function convert)
Navigation
[0] Message Index
Go to full version