Skip to content

Instantly share code, notes, and snippets.

@LouisStAmour
Created May 22, 2009 11:55
Show Gist options
  • Save LouisStAmour/116077 to your computer and use it in GitHub Desktop.
Save LouisStAmour/116077 to your computer and use it in GitHub Desktop.
Enable Drag & Drop reordering by default in SilverStripe (2.3.2 or higher)
<?php
# For the truly lazy (like myself) -- By Louis St-Amour
#
# A quick script to enable drag & drop reordering by default.
#
# To install:
# 1. Name this file MyCMSDecorator.php in mysite/code
# 2. Requires DataObject::add_extension('LeftAndMain', 'MyCMSDecorator');
# in mysite/_config.php
class MyCMSDecorator extends LeftAndMainDecorator {
function init() {
Requirements::javascript('jsparty/prototype.js');
Requirements::customScript(
'DragByDefaultAction = Class.create();
DragByDefaultAction.applyTo(\'#sortitems\');
DragByDefaultAction.prototype = {
initialize: function () {
this.checked=true;
$(\'sitetree\').makeDraggable();
}
}'
);
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment