OUR BLOG

Thoughts on development, design and the world we live in.



Drag Order Fix For New Blank Pages

By admin in Uncategorized. Posted on December 15th

We forked Drag Order extension, a cool extension for Radiant CMS, and fixed some stuff. What we didn’t take into account in our last fix was this case:

1) Create new pages, or import a data set with a ton of new pages
2) Try to reorder a page.

Turns out, the way it’s written, there’s an assumption that there’s just one new page:

So in our case we had multiple new pages-and the above would only work on one of them, the one being dragged. Later it would fail because there are other nil pages.

We ended up replacing the above block, to query for more records.

Once we have that set, we query the rest of the records to find out the inherent order. To find out this order of pages as the user sees it- and expects it, you could argue- we just mimic the query that’s on the index view for Radiant’s admin pages page, :order=> "position ASC"

We do a basic enumeration to determine the position in the array, and assign it to the page.

This works fine, but at this point in the code, the original arguments passed in - there are 4, two of which are the used to create local arrays of database records, are now out of date. So we reload those from the database:

By admin | Posted in Uncategorized | Tagged | Comments (0)

Post a Comment

Your email is never shared. Required fields are marked *

*
*