PostGres & MySQL Fixes For Drag Order Extension (for Radiant CMS)
We were experiencing an odd behavior with the very popular Drag Order extension. This extension allows you to re-order your pages in the Admin screen, and for that new order to be reflected in any loop on the front end, also via the children tag.
The aberrant behavior appears when you add a new page. If you try to drag and drop the page, the function re-numbers the list with duplicates.
take 3 pages:
1
2
3
Add a new page, 2.5. If you move it by drag and dropping to between 2 and 3, it will end up here:
1
2.5
2
3
If you look in the database, the position column, added by drag_order, on the Pages table, will have 2 “2″ positions.
This doesn’t occur in SqlLite; it does occur in MySQL and PostGres.
We installed PostGres, uninstalled Drag_Order (which involves some manual database dropping) and isolated the issue. We were unable to output to logger. Still trying to figure out that one. But we were able to run each statement in console, which is where we discovered the problem: the new page has a nil position value. When sorted, by the position, descending, the 2 databases in question consider Nil as a higher value and will float it to the top. After some other functions add and subtract position values to re-order siblings in the list, this value becomes “2″. Thus, a duplicate 2 in the list.
We changed the SQL to include a condition for no nulls. “:conditions => ” position is not null “. After re-testing, the lists were ordered correctly.
The fork for this fix is at: Banane fork of Radiant Drag Order on GitHub.
One Trackback
[...] geeky posts I’ve written- on Blazing-Cloud, PostGres & MySQL Fixes for Drag Order Extension- Radiant CMS. Share and [...]