Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Extension: SortableDataObject


Go to End


5 Posts   3054 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

27 December 2008 at 8:38am

An extension I created that allows arbitrary drag-and-drop sort of any subclass of DataObject of your choice.

Documentation is here: http://doc.silverstripe.com/doku.php?id=modules:sortabledataobject

Attached Files
Avatar
Ingo

Forum Moderator, 801 Posts

5 January 2009 at 10:37am

Nice redevelopment, UncleCheese! Especially for documenting your work on the wiki (http://doc.silverstripe.com/doku.php?id=modules:sortabledataobject). Some PHPDoc documentation would be nice as well ;)

Quote from UncleCheese (from a previous thread):
"I see what you're saying about mixing the markup into the model, and I rarely violate MVC in my work, but I just think this is a case where 99% of the time, the markup is going to be the same, so some "helper" functions are useful. Who wants to keep track of the class that the javascript library is going to be looking for? Might as well bundle it in. Users can always write their own instead. If you think about it, this is part of the reason why Ruby on Rails got so much hype. They were able to embrace MVC, but also recognize that using server-side functions to draw HTML could really streamline the development process without getting in the way."

I still think that HTML-tags shouldn't be in model-classes like SortableDataObject - for one, because the HTML-representation doesn't have anything to do with the data structure (you can usually configure the drag/drop-libs to work on different tags). You can expect users to act on a Iterator in their templates, and include the Requirements themselves (which means you don't need to get it in "through the backdoor" in SortableDataObjectSet->beginSortable(). Its a tradeoff between ease-of-use on one side, and architectural structure and flexibility on the other side.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

5 January 2009 at 11:35am

Thanks for your feedback, Ingo. I'll get to the PHPDoc once I figure out how the heck to do it. :-)

I agree, drawing markup in a DataModel is never pretty, and I always have to swallow hard when I do it, but I guess I think about it like a form field helper, for instance.

Think about the TabSet class that is used so frequently in SS development. What makes that so useful is that it does what we want it to do without troubling us with all the correct syntax and requirements. Do users really have to remember which javascript file it needs? How to set up the UL, the LI's, the spans? That's something I prefer to just work magically. I guess I look at drag-and-drop the same way. 99% of the time, we just want it to work.

I'm open to suggestions, as I'd love to see my work implemented. Do you have any ideas that would help it follow best practices more closely yet still provide gains in production time to the developer?

Avatar
boombox

Community Member, 44 Posts

18 February 2009 at 10:29pm

Greetings,
My question is looking to extend the SortableDataObject - I am looking to develop an ajax drag n drop cart functionality with the existing e-commerce Module
I have been playing with the script.aculo.us drag n drop code as seen at
http://demo.script.aculo.us/ & at http://design.theguigirl.com/cart.php (an entertaining cart :) and was looking to see if any extension of what you have developed could be brought into the drag n drop cart
OR if anyone has tried implmenting an ajax drag n drop with Silverstripe?

Regards

Avatar
UncleCheese

Forum Moderator, 4102 Posts

19 February 2009 at 3:24am

Edited: 19/02/2009 3:24am

Hi, smpmedia,

I think a drag-and-drop shopping cart is a great idea for the Ecomm module. I'm not sure you need to extend the SortableDataObject module, however, because it's entirely different functionality. You could harvest the javascript out of it and the PHP callback function, but other than that I'd want to start from scratch.

Avoid scriptaculous at all costs and use jQuery. The prototype/scriptaculous framework is a behemoth and it's not all that easy to use. Silverstripe is in the process of migrating all their JS to jQuery, anyway. Save yourself a lot of trouble.

Also, SortableDataObject is obsolete since it has been merged into the DataObjectManager extension.