Download the PHP package webfox/silverstripe-dropzone-sortable without Composer
On this page you can find all versions of the php package webfox/silverstripe-dropzone-sortable. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webfox/silverstripe-dropzone-sortable
More information about webfox/silverstripe-dropzone-sortable
Files in webfox/silverstripe-dropzone-sortable
Package silverstripe-dropzone-sortable
Short Description A Silverstripe extension to add drag/drop sorting to FileAttachmentField
License MIT
Informations about the package silverstripe-dropzone-sortable
Note:
Currently waiting on a pull request merge https://github.com/unclecheese/silverstripe-dropzone/pull/34 before this is
functional. Until this is merged if you would like to use this module then use the fork this pull request references.
Silverstripe Dropzone Sortable
This plugin allows drag/drop sorting via FileAttachmentField
from the dropzone package.
Installation Instructions
Composer
Run the following to add this module as a requirement and install it via composer.
Setup
Setting up the Relation
We need a SortOrder
column on the Image/File relation that FileAttachmentField
is hooked onto.
For a has_many to a custom DataObject
simply add the 'SortOrder' => 'int'
and private static $default_sort = 'SortOrder';
to the DataObject.
If you are relating to Image
or File
directly then you will need a many_many
setup with many_many_extrafields
and an accessor to loop over in the template
<% loop $SortedImages>...<% end_loop %>
or you can do <% loop $Images.Sort('SortOrder') %>...<% end_loop %>
.
This package will automatically sort the files in the FileAttachmentField.
Here is an example many_many
setup:
``
Enabling Sorting
To enable sorting simply call ->sortable()
on the FileAttachmentField
e.g. FileAttachmentField::create('Images')->sortable()->imagesOnly();
Customization
The only customization available is changing the sort column. FileAttachmentField::create('Images')->sortable()->setSortableColumn('OtherSortColumn');